:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(dashboards): let card edge zones yield to scrollbars underneath (#77302)
Thomas Obermüllerd682fdffc866
diff --git a/frontend/jest.setup.ts b/frontend/jest.setup.tsindex dc09952b6e10..084c3e232dc7 100644--- a/frontend/jest.setup.ts+++ b/frontend/jest.setup.ts@@ -121,6 +121,9 @@ mockResizeObserver.mockReturnValue({});(globalThis as any).ResizeObserver = mockResizeObserver+// jsdom has no layout, so hit-testing at a point can't return anything+document.elementsFromPoint = document.elementsFromPoint ?? ((): Element[] => [])+// Tell React Testing Library to use "data-attr" as the test ID attributeconfigure({ testIdAttribute: 'data-attr' })diff --git a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsxindex 3b7db381f43a..2419d96474df 100644--- a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx+++ b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx@@ -2,13 +2,87 @@ import '@testing-library/jest-dom'import { cleanup, fireEvent, render } from '@testing-library/react'-import { EditModeEdgeOverlay } from './EditModeEdgeOverlay'+import {+ EditModeEdgeOverlay,+ isPointInScrollbarGutter,+ useResizeHandleScrollbarPassThrough,+} from './EditModeEdgeOverlay'++type FakeElementConfig = {+ rect: { left: number; top: number; right: number; bottom: number }+ offsetWidth: number+ offsetHeight: number+ clientWidth: number+ clientHeight: number+ scrollWidth: number+ scrollHeight: number+ border?: number+ direction?: 'ltr' | 'rtl'+ overflowX?: string+ overflowY?: string+}++// A 400x300 element with classic 15px scrollbars: clientWidth/Height shrink by the scrollbar+// (and borders, when set), and content overflows on both axes unless a case says otherwise.+const SCROLLABLE_BASE: FakeElementConfig = {+ rect: { left: 0, top: 0, right: 400, bottom: 300 },+ offsetWidth: 400,+ offsetHeight: 300,+ clientWidth: 385,+ clientHeight: 285,+ scrollWidth: 800,+ scrollHeight: 600,+}describe('EditModeEdgeOverlay', () => {+ const styleConfig = new WeakMap<+ Element,+ { border: number; direction: string; overflowX: string; overflowY: string }+ >()+ const realGetComputedStyle = window.getComputedStyle+beforeEach(() => {cleanup()+ jest.spyOn(window, 'getComputedStyle').mockImplementation((el: Element): CSSStyleDeclaration => {+ const config = styleConfig.get(el)+ if (!config) {+ return realGetComputedStyle(el)+ }+ return {+ borderTopWidth: `${config.border}px`,+ borderBottomWidth: `${config.border}px`,+ borderLeftWidth: `${config.border}px`,+ borderRightWidth: `${config.border}px`,+ direction: config.direction,+ overflowX: config.overflowX,+ overflowY: config.overflowY,+ } as CSSStyleDeclaration+ })+ })++ afterEach(() => {+ jest.restoreAllMocks()})+ function fakeScrollableElement({+ rect,+ border = 0,+ direction = 'ltr',+ overflowX = 'auto',+ overflowY = 'auto',+ ...dimensions+ }: FakeElementConfig): HTMLElement {+ const el = document.createElement('div')+ Object.defineProperties(+ el,+ Object.fromEntries(Object.entries(dimensions).map(([key, value]) => [key, { value }]))+ )+ el.getBoundingClientRect = () =>+ ({ ...rect, width: rect.right - rect.left, height: rect.bottom - rect.top }) as DOMRect+ styleConfig.set(el, { border, direction, overflowX, overflowY })+ return el+ }+it('renders eight edge and corner hit areas with data attr', () => {const { getAllByTitle } = render(<EditModeEdgeOverlay onEnterEditMode={() => {}} />)@@ -62,4 +136,179 @@ describe('EditModeEdgeOverlay', () => {fireEvent.mouseLeave(zones[0])expect(container.querySelectorAll('.handle')).toHaveLength(8)})++ describe('scrollbar pass-through', () => {+ // A table tile's horizontal scrollbar renders in the card's bottom pixels, right under the+ // "s" zone. Presses aimed at it must scroll, not throw the user into edit mode.+ function renderWithScrollableUnderneath(): {+ onEnterEditMode: jest.Mock+ zones: HTMLElement[]+ scrollable: HTMLElement+ } {+ const onEnterEditMode = jest.fn()+ const { container, getAllByTitle } = render(<EditModeEdgeOverlay onEnterEditMode={onEnterEditMode} />)+ const zones = getAllByTitle('Click to edit layout')+ const scrollable = fakeScrollableElement(SCROLLABLE_BASE)+ container.appendChild(scrollable)+ jest.spyOn(document, 'elementsFromPoint').mockImplementation((x: number, y: number) =>+ x >= 0 && x <= 400 && y >= 0 && y <= 300 ? [zones[1], scrollable] : []+ )+ return { onEnterEditMode, zones, scrollable }+ }++ it('does not enter edit mode when the press lands on a scrollbar under the zone', () => {+ const { onEnterEditMode, zones } = renderWithScrollableUnderneath()++ fireEvent.mouseDown(zones[1], { clientX: 200, clientY: 292 })+ expect(onEnterEditMode).not.toHaveBeenCalled()++ fireEvent.mouseDown(zones[1], { clientX: 200, clientY: 150 })+ expect(onEnterEditMode).toHaveBeenCalledTimes(1)+ })++ it('lets pointer events through while hovering a scrollbar and recaptures them after', () => {+ const { zones } = renderWithScrollableUnderneath()++ fireEvent.mouseMove(zones[1], { clientX: 200, clientY: 292 })+ expect(zones[1]).toHaveStyle({ pointerEvents: 'none' })++ fireEvent.mouseMove(document, { clientX: 200, clientY: 150 })+ expect(zones[1]).not.toHaveStyle({ pointerEvents: 'none' })+ })++ it('yields every zone stacked on the point, not just the hovered one', () => {+ const { zones } = renderWithScrollableUnderneath()+ // Corner zones paint above edge zones near card corners. jsdom has no layout, so give the+ // sw corner and s edge zones their real overlapping geometry at the card's bottom-left.+ const rects: Array<[number, { left: number; top: number; right: number; bottom: number }]> = [+ [1, { left: 0, top: 288, right: 400, bottom: 302 }],+ [6, { left: -2, top: 284, right: 16, bottom: 302 }],+ ]+ for (const [index, rect] of rects) {+ zones[index].getBoundingClientRect = () =>+ ({ ...rect, width: rect.right - rect.left, height: rect.bottom - rect.top }) as DOMRect+ }++ fireEvent.mouseMove(zones[6], { clientX: 8, clientY: 292 })++ expect(zones[6]).toHaveStyle({ pointerEvents: 'none' })+ expect(zones[1]).toHaveStyle({ pointerEvents: 'none' })+ })+ })++ describe('useResizeHandleScrollbarPassThrough', () => {+ // In edit mode react-grid-layout's south resize handle covers a table tile's horizontal+ // scrollbar, so presses there resized the tile instead of scrolling.+ function Harness(): null {+ useResizeHandleScrollbarPassThrough(true)+ return null+ }++ function mountEditModeTile(): { gridItem: HTMLElement; handle: HTMLElement; scrollable: HTMLElement } {+ const gridItem = document.createElement('div')+ gridItem.className = 'react-grid-item'+ const scrollable = fakeScrollableElement(SCROLLABLE_BASE)+ const handle = document.createElement('span')+ handle.className = 'react-resizable-handle react-resizable-handle-s'+ handle.getBoundingClientRect = () =>+ ({ left: 0, top: 276, right: 368, bottom: 308, width: 368, height: 32 }) as DOMRect+ gridItem.append(scrollable, handle)+ document.body.appendChild(gridItem)+ jest.spyOn(document, 'elementsFromPoint').mockImplementation((x: number, y: number) =>+ x >= 0 && x <= 400 && y >= 0 && y <= 300 ? [handle, scrollable, gridItem] : []+ )+ render(<Harness />)+ return { gridItem, handle, scrollable }+ }++ afterEach(() => {+ document.querySelectorAll('.react-grid-item').forEach((el) => el.remove())+ })++ it('yields a resize handle while over a scrollbar and re-arms it after', () => {+ const { handle } = mountEditModeTile()++ fireEvent.mouseMove(handle, { clientX: 200, clientY: 292 })+ expect(handle.style.pointerEvents).toBe('none')++ fireEvent.mouseMove(document, { clientX: 200, clientY: 150 })+ expect(handle.style.pointerEvents).toBe('')+ })++ it('yields every handle stacked on the point, not just the hovered one', () => {+ const { gridItem, handle } = mountEditModeTile()+ const cornerHandle = document.createElement('span')+ cornerHandle.className = 'react-resizable-handle react-resizable-handle-sw'+ cornerHandle.getBoundingClientRect = () =>+ ({ left: -8, top: 276, right: 24, bottom: 308, width: 32, height: 32 }) as DOMRect+ gridItem.appendChild(cornerHandle)++ fireEvent.mouseMove(cornerHandle, { clientX: 8, clientY: 292 })++ expect(cornerHandle.style.pointerEvents).toBe('none')+ expect(handle.style.pointerEvents).toBe('none')+ })++ it('stops a press over a scrollbar from reaching the grid item, but not one elsewhere', () => {+ const { gridItem, scrollable } = mountEditModeTile()+ const gridItemPress = jest.fn()+ gridItem.addEventListener('mousedown', gridItemPress)++ fireEvent.mouseDown(scrollable, { clientX: 200, clientY: 292 })+ expect(gridItemPress).not.toHaveBeenCalled()++ fireEvent.mouseDown(scrollable, { clientX: 200, clientY: 150 })+ expect(gridItemPress).toHaveBeenCalledTimes(1)+ })+ })++ describe('isPointInScrollbarGutter', () => {+ test.each<[string, Partial<FakeElementConfig>, [number, number], boolean]>([+ ['point on the horizontal scrollbar', {}, [200, 292], true],+ ['point on the vertical scrollbar (ltr: right edge)', {}, [392, 150], true],+ ['point in the content area', {}, [200, 150], false],+ ['point outside the element', {}, [200, 310], false],+ [+ 'horizontal gutter reserved but content does not overflow',+ { scrollWidth: 385, scrollHeight: 285 },+ [200, 292],+ false,+ ],+ // Overlay scrollbars (macOS default): no layout gutter, so the edge band of a genuinely+ // scrollable element counts as scrollbar territory.+ ['overlay: point in the bottom scroll band', { clientWidth: 400, clientHeight: 300 }, [200, 292], true],+ ['overlay: point above the bottom scroll band', { clientWidth: 400, clientHeight: 300 }, [200, 283], false],+ ['overlay: point in the right scroll band', { clientWidth: 400, clientHeight: 300 }, [392, 150], true],+ [+ 'overlay rtl: scroll band sits on the left edge',+ { clientWidth: 400, clientHeight: 300, direction: 'rtl' as const },+ [7, 150],+ true,+ ],+ [+ 'overflow hidden clips without a scrollbar',+ { clientWidth: 400, clientHeight: 300, overflowX: 'hidden', overflowY: 'hidden' },+ [200, 292],+ false,+ ],+ [+ 'point on the bottom border, just below the gutter',+ { border: 2, clientWidth: 381, clientHeight: 281 },+ [200, 299],+ false,+ ],+ [+ 'point on the horizontal scrollbar of a bordered element',+ { border: 2, clientWidth: 381, clientHeight: 281 },+ [200, 290],+ true,+ ],+ ['rtl: vertical scrollbar sits on the left edge', { direction: 'rtl' }, [7, 150], true],+ ['rtl: right edge is plain content', { direction: 'rtl' }, [392, 150], false],+ ])('%s', (_name, overrides, [x, y], expected) => {+ expect(isPointInScrollbarGutter(fakeScrollableElement({ ...SCROLLABLE_BASE, ...overrides }), x, y)).toBe(+ expected+ )+ })+ })})diff --git a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.tsx b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.tsxindex 0b81af681305..055ba906bac7 100644--- a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.tsx+++ b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.tsx@@ -1,4 +1,4 @@-import React, { useRef, useState } from 'react'+import React, { useEffect, useRef, useState } from 'react'import { DashboardResizeHandles } from 'lib/components/Cards/handles'@@ -8,6 +8,8 @@ interface EditModeEdgeOverlayProps {onEnterEditMode: (event: React.MouseEvent<HTMLDivElement>, edge: EditModeEdge) => void}+const EDGE_ZONE_DATA_ATTR = 'dashboard-edit-mode-from-card-edge'+const edgeOverlayBaseStyle: React.CSSProperties = {position: 'absolute',zIndex: 5,@@ -36,13 +38,273 @@ const zones: { edge: EditModeEdge; style: React.CSSProperties; cursor: React.CSS{ edge: 'se', style: { ...cornerZoneStyle, bottom: -2, right: -2 }, cursor: 'se-resize' },]+/**+ * Overlay scrollbars (macOS default, and Chromium headless) occupy no layout space, so their exact+ * bounds cannot be measured. They render inside the scroll container along its bottom/right edge;+ * 16px matches the macOS hover-expanded track and comfortably covers Chromium's overlay thumb.+ */+const OVERLAY_SCROLLBAR_BAND = 16++const isScrollableOverflow = (overflow: string): boolean =>+ // 'overlay' is legacy WebKit; Chrome computes it to 'auto' but include it for safety.+ overflow === 'auto' || overflow === 'scroll' || overflow === 'overlay'++/**+ * Whether the viewport point (x, y) lies on a functional scrollbar of `el`.+ * "Functional" means the content actually overflows on that axis, so a press there would grab the+ * scrollbar rather than hit an empty reserved gutter. Classic scrollbars occupy layout space+ * (`offsetHeight - clientHeight`), which gives their exact bounds. Overlay scrollbars (macOS+ * default) occupy none, so for a scrollable element without a gutter the edge band where the+ * overlay scrollbar materializes counts as scrollbar territory even while the thumb is hidden;+ * a press there while it's hidden just falls through to the content, matching native behavior.+ */+export function isPointInScrollbarGutter(el: HTMLElement, x: number, y: number): boolean {+ const style = window.getComputedStyle(el)+ const borderTop = parseFloat(style.borderTopWidth) || 0+ const borderBottom = parseFloat(style.borderBottomWidth) || 0+ const borderLeft = parseFloat(style.borderLeftWidth) || 0+ const borderRight = parseFloat(style.borderRightWidth) || 0+ const rect = el.getBoundingClientRect()++ // offsetHeight spans the border box; clientHeight excludes borders and the horizontal scrollbar,+ // so the difference minus borders is the scrollbar's rendered height (0 for overlay scrollbars).+ // The > 1 threshold absorbs the integer rounding of offset/client dimensions.+ const horizontalGutter = el.offsetHeight - el.clientHeight - borderTop - borderBottom+ const canScrollX = el.scrollWidth - el.clientWidth > 1+ const horizontalBand =+ horizontalGutter > 1 && canScrollX+ ? horizontalGutter+ : canScrollX && isScrollableOverflow(style.overflowX)+ ? OVERLAY_SCROLLBAR_BAND+ : 0+ if (horizontalBand > 0) {+ const bandTop = rect.bottom - borderBottom - horizontalBand+ if (+ y >= bandTop &&+ y <= rect.bottom - borderBottom &&+ x >= rect.left + borderLeft &&+ x <= rect.right - borderRight+ ) {+ return true+ }+ }++ const verticalGutter = el.offsetWidth - el.clientWidth - borderLeft - borderRight+ const canScrollY = el.scrollHeight - el.clientHeight > 1+ const verticalBand =+ verticalGutter > 1 && canScrollY+ ? verticalGutter+ : canScrollY && isScrollableOverflow(style.overflowY)+ ? OVERLAY_SCROLLBAR_BAND+ : 0+ if (verticalBand > 0) {+ const bandLeft = style.direction === 'rtl' ? rect.left + borderLeft : rect.right - borderRight - verticalBand+ if (+ x >= bandLeft &&+ x <= bandLeft + verticalBand &&+ y >= rect.top + borderTop &&+ y <= rect.bottom - borderBottom+ ) {+ return true+ }+ }++ return false+}++/** Whether any element of the card under the viewport point shows a functional scrollbar there. */+function pointIsOverScrollbarInside(container: HTMLElement, x: number, y: number): boolean {+ return document+ .elementsFromPoint(x, y)+ .some(+ (el) =>+ el instanceof HTMLElement &&+ el.dataset.attr !== EDGE_ZONE_DATA_ATTR &&+ container.contains(el) &&+ isPointInScrollbarGutter(el, x, y)+ )+}++/**+ * In edit mode react-grid-layout's resize handles cover the card edges — the south handle is 32px+ * tall and reaches 24px into the tile (see DashboardItems.scss), fully burying a table's horizontal+ * scrollbar — so they must yield to scrollbars the same way the view-mode zones above do. One+ * document-level watcher covers every tile: it hands a hovered handle's pixels to the scrollbar via+ * `pointer-events: none` and re-arms it once the pointer leaves. The capture-phase mousedown guard+ * covers what the hover hand-off can't: a press that lands before any mousemove, or a press on the+ * scrollbar itself, which would otherwise bubble into react-grid-layout and start a resize or tile+ * drag. Stopping propagation (without preventDefault) keeps the native scrollbar interaction alive.+ */+export function useResizeHandleScrollbarPassThrough(enabled: boolean): void {+ useEffect(() => {+ if (!enabled) {+ return+ }+ const yielded = new Set<HTMLElement>()++ const rearm = (event: MouseEvent): void => {+ for (const handle of yielded) {+ const gridItem = handle.closest('.react-grid-item')+ const rect = handle.getBoundingClientRect()+ const inHandle =+ handle.isConnected &&+ event.clientX >= rect.left &&+ event.clientX <= rect.right &&+ event.clientY >= rect.top &&+ event.clientY <= rect.bottom+ if (+ !inHandle ||+ !(gridItem instanceof HTMLElement) ||+ !pointIsOverScrollbarInside(gridItem, event.clientX, event.clientY)+ ) {+ handle.style.pointerEvents = ''+ yielded.delete(handle)+ }+ }+ }++ const handleMove = (event: MouseEvent): void => {+ if (event.buttons !== 0) {+ return // don't re-target pixels mid-drag or mid-resize+ }+ rearm(event)+ const hovered = event.target instanceof Element ? event.target.closest('.react-resizable-handle') : null+ const gridItem = hovered?.closest('.react-grid-item')+ if (+ !(hovered instanceof HTMLElement) ||+ !(gridItem instanceof HTMLElement) ||+ yielded.has(hovered) ||+ !pointIsOverScrollbarInside(gridItem, event.clientX, event.clientY)+ ) {+ return+ }+ // Corner handles overlap the edge handles at the ends, so yield every handle stacked on+ // the point at once — otherwise the one beneath swallows a press until its own mousemove.+ for (const handle of gridItem.querySelectorAll<HTMLElement>('.react-resizable-handle')) {+ const rect = handle.getBoundingClientRect()+ if (+ event.clientX >= rect.left &&+ event.clientX <= rect.right &&+ event.clientY >= rect.top &&+ event.clientY <= rect.bottom+ ) {+ handle.style.pointerEvents = 'none'+ yielded.add(handle)+ }+ }+ }++ const handlePressCapture = (event: MouseEvent): void => {+ const gridItem = event.target instanceof Element ? event.target.closest('.react-grid-item') : null+ if (gridItem instanceof HTMLElement && pointIsOverScrollbarInside(gridItem, event.clientX, event.clientY)) {+ event.stopPropagation()+ }+ }++ document.addEventListener('mousemove', handleMove)+ document.addEventListener('mousedown', handlePressCapture, true)+ return () => {+ document.removeEventListener('mousemove', handleMove)+ document.removeEventListener('mousedown', handlePressCapture, true)+ for (const handle of yielded) {+ handle.style.pointerEvents = ''+ }+ }+ }, [enabled])+}+export const EditModeEdgeOverlay: React.FC<EditModeEdgeOverlayProps> = ({ onEnterEditMode }) => {const [hovering, setHovering] = useState(false)// Count entered zones rather than toggling a boolean, so following the border across overlapping// edge/corner zones never dips to "not hovering" for a frame and flickers the handles.const hoverCount = useRef(0)+ // Zones whose pixels currently sit on top of a scrollbar of the tile's content. They get+ // `pointer-events: none` so presses and wheel events reach the scrollbar natively: a native+ // scrollbar drag only engages when the browser hit-tests the pointer to the scrollable element+ // itself, so an intercept-then-forward approach cannot work. The main case is a table insight+ // whose horizontal scrollbar renders in the card's bottom pixels, exactly under the "s" zone.+ const [scrollbarPassThroughEdges, setScrollbarPassThroughEdges] = useState<ReadonlySet<EditModeEdge>>(new Set())+ const zoneRefs = useRef(new Map<EditModeEdge, HTMLDivElement | null>())++ const releaseHover = (): void => {+ hoverCount.current = Math.max(0, hoverCount.current - 1)+ if (hoverCount.current === 0) {+ setHovering(false)+ }+ }++ const evaluateScrollbarPassThrough = (event: React.MouseEvent<HTMLDivElement>, edge: EditModeEdge): void => {+ const container = event.currentTarget.parentElement+ if (!container || scrollbarPassThroughEdges.has(edge)) {+ return+ }+ const { clientX, clientY } = event+ if (!pointIsOverScrollbarInside(container, clientX, clientY)) {+ return+ }+ // Corner zones paint above edge zones, so several zones can stack on these pixels. Yield every+ // zone whose rect contains the point, not just the hovered one: a zone beneath only receives its+ // own mousemove after the one above yields, and until then it would swallow a press aimed at the+ // scrollbar (handlePress keeps it out of edit mode, but the press reaches no scrollbar either).+ setScrollbarPassThroughEdges((prev) => {+ let next: Set<EditModeEdge> | null = null+ for (const [zoneEdge, zone] of zoneRefs.current) {+ if (!zone || prev.has(zoneEdge)) {+ continue+ }+ const rect = zone.getBoundingClientRect()+ const containsPoint =+ clientX >= rect.left && clientX <= rect.right && clientY >= rect.top && clientY <= rect.bottom+ if (zoneEdge === edge || containsPoint) {+ next = next ?? new Set(prev)+ next.add(zoneEdge)+ }+ }+ return next ?? prev+ })+ // The zone's own mouseleave won't fire once it ignores pointer events, so release here.+ releaseHover()+ }++ useEffect(() => {+ if (scrollbarPassThroughEdges.size === 0) {+ return+ }+ // While any zone is letting events through, watch the pointer at the document level and+ // re-enable the zone once the pointer is no longer over the scrollbar beneath it.+ const handleMove = (event: MouseEvent): void => {+ setScrollbarPassThroughEdges((prev) => {+ let next: Set<EditModeEdge> | null = null+ for (const edge of prev) {+ const zone = zoneRefs.current.get(edge)+ const container = zone?.parentElement+ const rect = zone?.getBoundingClientRect()+ const inZone =+ !!rect &&+ event.clientX >= rect.left &&+ event.clientX <= rect.right &&+ event.clientY >= rect.top &&+ event.clientY <= rect.bottom+ if (!inZone || !container || !pointIsOverScrollbarInside(container, event.clientX, event.clientY)) {+ next = next ?? new Set(prev)+ next.delete(edge)+ }+ }+ return next ?? prev+ })+ }+ document.addEventListener('mousemove', handleMove)+ return () => document.removeEventListener('mousemove', handleMove)+ }, [scrollbarPassThroughEdges])const handlePress = (event: React.MouseEvent<HTMLDivElement>, edge: EditModeEdge): void => {+ // A fast press can land before any mousemove had a chance to hand the zone's pixels over to+ // the scrollbar below. The press is lost either way (it targeted the zone), but it must not+ // throw the user into edit mode when they were aiming at a scrollbar.+ const container = event.currentTarget.parentElement+ if (container && pointIsOverScrollbarInside(container, event.clientX, event.clientY)) {+ return+ }// Treat any press (click or drag attempt) as intent to editevent.preventDefault()event.stopPropagation()@@ -55,22 +317,27 @@ export const EditModeEdgeOverlay: React.FC<EditModeEdgeOverlayProps> = ({ onEnte{zones.map(({ edge, style, cursor }) => (<divkey={edge}+ ref={(el) => {+ zoneRefs.current.set(edge, el)+ }}onMouseDown={(event) => handlePress(event, edge)}- onMouseEnter={() => {+ onMouseMove={(event) => evaluateScrollbarPassThrough(event, edge)}+ onMouseEnter={(event) => {hoverCount.current += 1setHovering(true)+ evaluateScrollbarPassThrough(event, edge)}}- onMouseLeave={() => {- hoverCount.current = Math.max(0, hoverCount.current - 1)- if (hoverCount.current === 0) {- setHovering(false)- }- }}+ onMouseLeave={() => releaseHover()}aria-hidden="true"title="Click to edit layout"- data-attr="dashboard-edit-mode-from-card-edge"+ data-attr={EDGE_ZONE_DATA_ATTR}// eslint-disable-next-line react/forbid-dom-props- style={{ ...edgeOverlayBaseStyle, ...style, cursor }}+ style={{+ ...edgeOverlayBaseStyle,+ ...style,+ cursor,+ ...(scrollbarPassThroughEdges.has(edge) ? { pointerEvents: 'none' } : {}),+ }}/>))}</>diff --git a/frontend/src/scenes/dashboard/DashboardItems.tsx b/frontend/src/scenes/dashboard/DashboardItems.tsxindex 1d3640627fe0..77f98350c15d 100644--- a/frontend/src/scenes/dashboard/DashboardItems.tsx+++ b/frontend/src/scenes/dashboard/DashboardItems.tsx@@ -12,7 +12,7 @@ import { getDashboardWidgetFetchDisplayError } from '@posthog/products-dashboardimport { ApiError } from 'lib/api'import { InsightCard } from 'lib/components/Cards/InsightCard'-import { EditModeEdge } from 'lib/components/Cards/InsightCard/EditModeEdgeOverlay'+import { EditModeEdge, useResizeHandleScrollbarPassThrough } from 'lib/components/Cards/InsightCard/EditModeEdgeOverlay'import { LemonBanner } from 'lib/lemon-ui/LemonBanner'import { LemonMenuItem } from 'lib/lemon-ui/LemonMenu'import { DashboardEventSource, eventUsageLogic } from 'lib/utils/eventUsageLogic'@@ -291,6 +291,8 @@ export function DashboardItems({ showCreateAnomalyAlertButton }: DashboardItemsP[layoutEditMode, isMobileView, isLayoutZoomToggled])+ useResizeHandleScrollbarPassThrough(layoutEditMode && !isMobileView)+const onEnterEditModeFromEdge = useMemo(() =>canEnterEditModeFromEdge