Skip to content

Commit

Permalink
[kbn-grid-layout] Make drag preview absolute positioned (elastic#20…
Browse files Browse the repository at this point in the history
…8247)

## Summary

This PR positions the drag preview via `absolute` positioning. This is a
potential fix for `EuiResizeObservers` being fired unnecessarily.


### Checklist

- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
Heenawter authored Jan 24, 2025
1 parent 6370aa2 commit 1ff451a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export const DragPreview = ({
} else {
const panel = proposedGridLayout[rowIndex].panels[activePanel.id];
dragPreviewRef.current.style.display = 'block';
dragPreviewRef.current.style.gridColumnStart = `${panel.column + 1}`;
dragPreviewRef.current.style.gridColumnEnd = `${panel.column + 1 + panel.width}`;
dragPreviewRef.current.style.gridRowStart = `${panel.row + 1}`;
dragPreviewRef.current.style.gridRowEnd = `${panel.row + 1 + panel.height}`;
dragPreviewRef.current.style.height = `calc(1px * (${panel.height} * (var(--kbnGridRowHeight) + var(--kbnGridGutterSize)) - var(--kbnGridGutterSize)))`;
dragPreviewRef.current.style.width = `calc(1px * (${panel.width} * (var(--kbnGridColumnWidth) + var(--kbnGridGutterSize)) - var(--kbnGridGutterSize)))`;
dragPreviewRef.current.style.top = `calc(1px * (${panel.row} * (var(--kbnGridRowHeight) + var(--kbnGridGutterSize))))`;
dragPreviewRef.current.style.left = `calc(1px * (${panel.column} * (var(--kbnGridColumnWidth) + var(--kbnGridGutterSize))))`;
}
});

Expand All @@ -61,6 +61,7 @@ export const DragPreview = ({
css={css`
display: none;
pointer-events: none;
position: absolute;
`}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const GridRow = forwardRef<HTMLDivElement, GridRowProps>(
css={css`
height: 100%;
display: grid;
position: relative;
justify-items: stretch;
transition: background-color 300ms linear;
${initialStyles};
Expand Down

0 comments on commit 1ff451a

Please sign in to comment.