: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
feat(dashboards): reveal tile resize handles on border hover (#69744)
Matt Pua1d5a79e5595b
diff --git a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsxindex dbce5ee79d4f..3b7db381f43a 100644--- a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx+++ b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx@@ -9,13 +9,13 @@ describe('EditModeEdgeOverlay', () => {cleanup()})- it('renders four edge hit areas with data attr', () => {+ it('renders eight edge and corner hit areas with data attr', () => {const { getAllByTitle } = render(<EditModeEdgeOverlay onEnterEditMode={() => {}} />)- const edges = getAllByTitle('Click to edit layout')- expect(edges).toHaveLength(4)- edges.forEach((edge) => {- expect(edge).toHaveAttribute('data-attr', 'dashboard-edit-mode-from-card-edge')+ const zones = getAllByTitle('Click to edit layout')+ expect(zones).toHaveLength(8)+ zones.forEach((zone) => {+ expect(zone).toHaveAttribute('data-attr', 'dashboard-edit-mode-from-card-edge')})})@@ -24,14 +24,42 @@ describe('EditModeEdgeOverlay', () => {[1, 's'],[2, 'w'],[3, 'e'],- ])('calls onEnterEditMode with the pressed edge when edge %i is pressed', (edgeIndex, expectedEdge) => {+ [4, 'nw'],+ [5, 'ne'],+ [6, 'sw'],+ [7, 'se'],+ ])('calls onEnterEditMode with the pressed direction when zone %i is pressed', (zoneIndex, expectedEdge) => {const onEnterEditMode = jest.fn()const { getAllByTitle } = render(<EditModeEdgeOverlay onEnterEditMode={onEnterEditMode} />)- const edges = getAllByTitle('Click to edit layout')+ const zones = getAllByTitle('Click to edit layout')- fireEvent.mouseDown(edges[edgeIndex])+ fireEvent.mouseDown(zones[zoneIndex])expect(onEnterEditMode).toHaveBeenCalledTimes(1)expect(onEnterEditMode).toHaveBeenCalledWith(expect.anything(), expectedEdge)})++ it('reveals all resize handles while any zone is hovered', () => {+ const { container, getAllByTitle } = render(<EditModeEdgeOverlay onEnterEditMode={() => {}} />)+ const zones = getAllByTitle('Click to edit layout')++ expect(container.querySelectorAll('.handle')).toHaveLength(0)++ fireEvent.mouseEnter(zones[0])+ expect(container.querySelectorAll('.handle')).toHaveLength(8)++ fireEvent.mouseLeave(zones[0])+ expect(container.querySelectorAll('.handle')).toHaveLength(0)+ })++ it('keeps handles shown while moving between overlapping zones', () => {+ const { container, getAllByTitle } = render(<EditModeEdgeOverlay onEnterEditMode={() => {}} />)+ const zones = getAllByTitle('Click to edit layout')++ // Enter a corner, then the adjacent edge, before leaving the corner — count must not hit zero.+ fireEvent.mouseEnter(zones[0])+ fireEvent.mouseEnter(zones[4])+ fireEvent.mouseLeave(zones[0])+ expect(container.querySelectorAll('.handle')).toHaveLength(8)+ })})diff --git a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.tsx b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.tsxindex a283f51bda1b..0b81af681305 100644--- a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.tsx+++ b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.tsx@@ -1,6 +1,8 @@-import React from 'react'+import React, { useRef, useState } from 'react'-export type EditModeEdge = 'n' | 's' | 'w' | 'e'+import { DashboardResizeHandles } from 'lib/components/Cards/handles'++export type EditModeEdge = 'n' | 's' | 'w' | 'e' | 'nw' | 'ne' | 'sw' | 'se'interface EditModeEdgeOverlayProps {onEnterEditMode: (event: React.MouseEvent<HTMLDivElement>, edge: EditModeEdge) => void@@ -15,18 +17,31 @@ const edgeOverlayBaseStyle: React.CSSProperties = {background: 'none',}-const edges: { edge: EditModeEdge; style: React.CSSProperties; cursor: React.CSSProperties['cursor'] }[] = [- // top – vertical resize cursor- { edge: 'n', style: { left: 0, right: 0, top: -6, height: 12 }, cursor: 'ns-resize' },- // bottom – vertical resize cursor- { edge: 's', style: { left: 0, right: 0, bottom: -6, height: 12 }, cursor: 'ns-resize' },- // left – horizontal resize cursor+// Top/bottom zones hug the border and reach mostly *into* the tile: the inline "insert tile" overlay owns the+// row gap between tiles (see InsertTileOverlay), so keeping these off the gap avoids fighting it for the same+// pixels. They still win the shared border pixel via a higher z-index. Left/right never touch the insert line.+const TOP_BOTTOM_Z = 7+// Corners sit above edges so a press in the corner resolves to the diagonal handle.+const cornerZoneStyle: React.CSSProperties = { zIndex: TOP_BOTTOM_Z, width: 18, height: 18 }++const zones: { edge: EditModeEdge; style: React.CSSProperties; cursor: React.CSSProperties['cursor'] }[] = [+ // Shallow on top (the card header/menu lives just below) and deeper on the bottom for a comfortable target.+ { edge: 'n', style: { left: 0, right: 0, top: -2, height: 10, zIndex: TOP_BOTTOM_Z }, cursor: 'ns-resize' },+ { edge: 's', style: { left: 0, right: 0, bottom: -2, height: 14, zIndex: TOP_BOTTOM_Z }, cursor: 'ns-resize' },{ edge: 'w', style: { top: 0, bottom: 0, left: -6, width: 12 }, cursor: 'ew-resize' },- // right – horizontal resize cursor{ edge: 'e', style: { top: 0, bottom: 0, right: -6, width: 12 }, cursor: 'ew-resize' },+ { edge: 'nw', style: { ...cornerZoneStyle, top: -2, left: -2 }, cursor: 'nw-resize' },+ { edge: 'ne', style: { ...cornerZoneStyle, top: -2, right: -2 }, cursor: 'ne-resize' },+ { edge: 'sw', style: { ...cornerZoneStyle, bottom: -2, left: -2 }, cursor: 'sw-resize' },+ { edge: 'se', style: { ...cornerZoneStyle, bottom: -2, right: -2 }, cursor: 'se-resize' },]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)+const handlePress = (event: React.MouseEvent<HTMLDivElement>, edge: EditModeEdge): void => {// Treat any press (click or drag attempt) as intent to editevent.preventDefault()@@ -36,10 +51,21 @@ export const EditModeEdgeOverlay: React.FC<EditModeEdgeOverlayProps> = ({ onEntereturn (<>- {edges.map(({ edge, style, cursor }) => (+ {hovering && <DashboardResizeHandles />}+ {zones.map(({ edge, style, cursor }) => (<divkey={edge}onMouseDown={(event) => handlePress(event, edge)}+ onMouseEnter={() => {+ hoverCount.current += 1+ setHovering(true)+ }}+ onMouseLeave={() => {+ hoverCount.current = Math.max(0, hoverCount.current - 1)+ if (hoverCount.current === 0) {+ setHovering(false)+ }+ }}aria-hidden="true"title="Click to edit layout"data-attr="dashboard-edit-mode-from-card-edge"diff --git a/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx b/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsxindex 9eeabd6aceb6..85a551fcaaa1 100644--- a/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx+++ b/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx@@ -47,8 +47,9 @@ describe('TextCard', () => {/>)+ // Wiring guard only: the exact zone count is pinned by EditModeEdgeOverlay's own test.const edges = getAllByTitle('Click to edit layout')- expect(edges).toHaveLength(4)+ expect(edges.length).toBeGreaterThan(0)fireEvent.mouseDown(edges[0])expect(onEnterEditModeFromEdge).toHaveBeenCalledTimes(1)diff --git a/frontend/src/lib/components/Cards/handles.tsx b/frontend/src/lib/components/Cards/handles.tsxindex 9b958525d5b4..d74051bb8959 100644--- a/frontend/src/lib/components/Cards/handles.tsx+++ b/frontend/src/lib/components/Cards/handles.tsx@@ -52,15 +52,10 @@ function ResizeHandle2D({ className }: { className?: string } = {}): JSX.Elementexport function DashboardResizeHandles(): JSX.Element {return (<>- {/* Top/bottom resize */}<ResizeHandle1D orientation="horizontal" className="top" /><ResizeHandle1D orientation="horizontal" className="bottom" />-- {/* Left/right resize */}<ResizeHandle1D orientation="vertical" className="right" /><ResizeHandle1D orientation="vertical" className="left" />-- {/* Corner handles */}<ResizeHandle2D className="bottom-right" /><ResizeHandle2D className="bottom-left" /><ResizeHandle2D className="top-left" />diff --git a/frontend/src/scenes/dashboard/DashboardItems.scss b/frontend/src/scenes/dashboard/DashboardItems.scssindex 12c9669d0de5..349aed9d8d1e 100644--- a/frontend/src/scenes/dashboard/DashboardItems.scss+++ b/frontend/src/scenes/dashboard/DashboardItems.scss@@ -22,6 +22,11 @@/* Skip rendering for off-screen tiles during resize/reflow */content-visibility: auto;contain-intrinsic-size: auto 30rem;++ /* content-visibility paint-clips the resize handles revealed on border hover; lift it while one shows */+ &:has(> .handle) {+ content-visibility: visible;+ }}}diff --git a/frontend/src/scenes/dashboard/InsertTileOverlay.tsx b/frontend/src/scenes/dashboard/InsertTileOverlay.tsxindex b1c349ed5e62..deb3b74a6402 100644--- a/frontend/src/scenes/dashboard/InsertTileOverlay.tsx+++ b/frontend/src/scenes/dashboard/InsertTileOverlay.tsx@@ -101,6 +101,8 @@ export function InsertTileOverlay({}return (+ // Stays below the tiles' edge-resize hover zones (see EditModeEdgeOverlay), so hovering a tile border+ // grabs the resize handle rather than this insert line. Keep this under those zones' z-index if changed.// eslint-disable-next-line react/forbid-dom-props<div ref={containerRef} className="absolute inset-0 pointer-events-none" style={{ zIndex: 6 }}>{boundaries.map((boundary) => (@@ -119,10 +121,9 @@ export function InsertTileOverlay({)}-// Generous transparent hover zone so the thin line/"+" is easy to target (the visible bits stay-// centered on the row boundary). Larger than the inter-row gap, so it bleeds a little into the-// adjacent tiles — that's the intended trade-off for a comfortable hit area.-const HOVER_HIT_HEIGHT = 28+// Transparent hover zone centered on the row boundary. Kept within the inter-row gap (12px < the 16px+// gap) so it doesn't bleed onto the adjacent tile borders, which carry their own resize-on-hover zones.+const HOVER_HIT_HEIGHT = 12// Keep the "+" fully on the strip when the cursor is near either end.const BUTTON_EDGE_PADDING = 16diff --git a/frontend/src/scenes/dashboard/editLayoutGesture.test.ts b/frontend/src/scenes/dashboard/editLayoutGesture.test.tsindex b7df4b16b55e..b34ae5ce4263 100644--- a/frontend/src/scenes/dashboard/editLayoutGesture.test.ts+++ b/frontend/src/scenes/dashboard/editLayoutGesture.test.ts@@ -1,5 +1,6 @@import type { MouseEvent as ReactMouseEvent } from 'react'+import { EditModeEdge } from 'lib/components/Cards/InsightCard/EditModeEdgeOverlay'import {continueDragGestureInEditMode,continueResizeGestureInEditMode,@@ -23,8 +24,13 @@ describe('editLayoutGesture', () => {['w', 0, 195, 'sw'],['e', 300, 10, 'ne'],['e', 300, 195, 'se'],+ // Corner presses pass through directly, ignoring the edge-upgrade thresholds.+ ['nw', 150, 100, 'nw'],+ ['ne', 150, 100, 'ne'],+ ['sw', 150, 100, 'sw'],+ ['se', 150, 100, 'se'],])('maps edge %s at (%i, %i) to handle %s', (edge, clientX, clientY, expected) => {- expect(resolveResizeHandleDirection(edge as 'n' | 's' | 'w' | 'e', rect, clientX, clientY)).toBe(expected)+ expect(resolveResizeHandleDirection(edge as EditModeEdge, rect, clientX, clientY)).toBe(expected)})})diff --git a/frontend/src/scenes/dashboard/editLayoutGesture.ts b/frontend/src/scenes/dashboard/editLayoutGesture.tsindex 6bd1a6f1da33..b77d56105629 100644--- a/frontend/src/scenes/dashboard/editLayoutGesture.ts+++ b/frontend/src/scenes/dashboard/editLayoutGesture.ts@@ -14,6 +14,10 @@ export function resolveResizeHandleDirection(clientX: number,clientY: number): string {+ // Corner presses already name the diagonal handle directly.+ if (['nw', 'ne', 'sw', 'se'].includes(edge)) {+ return edge+ }if (edge === 'n' || edge === 's') {if (clientX - rect.left <= CORNER_THRESHOLD_PX) {return `${edge}w`