From 6cc788c4b17fdb627feeceadd457c425478eefd1 Mon Sep 17 00:00:00 2001 From: Hannah Mudge Date: Mon, 3 Feb 2025 15:43:24 -0700 Subject: [PATCH] [kbn-grid-layout] Disable pointer events on drag + resize (#208647) ## Summary This PR greatly improves the performance of `kbn-grid-layout` on drag + resize by disabling pointer events during these actions. This is especially evident when dragging over panels that have their own mouse event listeners. | Before | After | |--------|--------| | ![image](https://github.com/user-attachments/assets/efea4bd0-e950-4d71-8485-f5f123240e5b) | ![image](https://github.com/user-attachments/assets/15b044b2-521c-4bf5-a6cb-673c3a2affe4) | | ![image](https://github.com/user-attachments/assets/7daa6c96-ff38-4336-beb8-e7378445e589) | ![image](https://github.com/user-attachments/assets/37bb55c8-e757-4311-ab25-cb0c4cd18f58) | | ![image](https://github.com/user-attachments/assets/1fbe721d-690f-4a57-aaab-c07f575e5d41) | ![image](https://github.com/user-attachments/assets/6bdfdd40-9e58-4750-b152-cec2b12065fc) | ### 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) --- .../private/kbn-grid-layout/grid/grid_height_smoother.tsx | 3 --- .../packages/private/kbn-grid-layout/grid/grid_layout.tsx | 6 ++++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/platform/packages/private/kbn-grid-layout/grid/grid_height_smoother.tsx b/src/platform/packages/private/kbn-grid-layout/grid/grid_height_smoother.tsx index 213b1dc80a63d..792d8bb1aabe7 100644 --- a/src/platform/packages/private/kbn-grid-layout/grid/grid_height_smoother.tsx +++ b/src/platform/packages/private/kbn-grid-layout/grid/grid_height_smoother.tsx @@ -33,14 +33,11 @@ export const GridHeightSmoother = ({ if (!interactionEvent) { smoothHeightRef.current.style.minHeight = `${dimensions.height}px`; - smoothHeightRef.current.style.userSelect = 'auto'; return; } - smoothHeightRef.current.style.minHeight = `${ smoothHeightRef.current.getBoundingClientRect().height }px`; - smoothHeightRef.current.style.userSelect = 'none'; }); return () => { diff --git a/src/platform/packages/private/kbn-grid-layout/grid/grid_layout.tsx b/src/platform/packages/private/kbn-grid-layout/grid/grid_layout.tsx index 1d285046f89f4..f42d61321ad59 100644 --- a/src/platform/packages/private/kbn-grid-layout/grid/grid_layout.tsx +++ b/src/platform/packages/private/kbn-grid-layout/grid/grid_layout.tsx @@ -161,6 +161,12 @@ export const GridLayout = ({ css={css` padding: calc(var(--kbnGridGutterSize) * 1px); + // disable pointer events and user select on drag + resize + &:has(.kbnGridPanel--active) { + user-select: none; + pointer-events: none; + } + &:has(.kbnGridPanel--expanded) { ${expandedPanelStyles} }