Skip to content

: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.

feat(dashboards): simplify resize grips and show them on hover (#119602)

Matt Pua6f3b99cca6d0
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index b59a8496c029..f02dc835034e 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -453,13 +453,13 @@ snapshots:
components-bulkupdatetagsbutton--replace-mode--light:
hash: v1.k794b7964.049a5c3e535fe4407b74eefdcb54fd445bc805a1ce184a374a10d48d619363a6._GmRNKpvgknNL2cOUGUMzXkh_u5a6qe-jscOFsAA4HM
components-cards-button-tile-card--template--dark:
- hash: v1.k794b7964.e319229c46eb99bfc96474267da771f0e5cd68dbcd3f22b673cad29299e7b7c1.cXTNKkhjePnQSochAtS2mVIydyQgrN3DUeMyiePg0_o
+ hash: v1.k794b7964.95188fc0b39ff6c648939c5bae697a1c5ac6f77520297acb9c200abb38fe5fe9.1IOFvHCPhkBmqpOt_qPCfpyhPnWT9Gj7eMoIFTwg6oc
components-cards-button-tile-card--template--light:
- hash: v1.k794b7964.904b0a32641c5a7cf14bfa3c4c40fa5adb03e0af4807f4f37aba375c8655c385.XJk6J04tj1-gtrxtVed0JmDyHomY0UbyUdDoDtHdOhQ
+ hash: v1.k794b7964.6bfe4e0c90c94618b1d0842638710b48411ec9e7725ce85e26d388a32d609953.PO_9SvfehmdHAivVZ2Uc-q_s_XubTwNxEm-BUrKXnWE
components-cards-button-tile-card--transparent-background--dark:
- hash: v1.k794b7964.cffc64f78ae26de6277d8682b557ecc981fc49610706ec37554e20e900814bd1.taOFW3FWlyc-QWmYr88T5S4Fv4gPnYFvTNocOYlt-V0
+ hash: v1.k794b7964.987255b17b0844a239eb40f9d696ccf9ab6fadff2b414a2364343d4672386c29.iG2_mUJ1R2EV5Pn_kW31RWZqFIExImqhGoIEEXrtOco
components-cards-button-tile-card--transparent-background--light:
- hash: v1.k794b7964.935526cdb7a3c195d5e81fc26a809283913ae44f2fc0cbc6ad896b4eadabbd13.TFdCXZ8b2G5fFOC5zaYL5gx-GevjhkQHx0XIcHrlqIE
+ hash: v1.k794b7964.e9e06d43804799932c1ba8d4a4280cecc3eb07a6108993a30a476d22309850e6.iZl_jsl6oLeIP_LIRY3vGbuhLM-1pyoQKF5muaE_bjs
components-cards-button-tile-card--with-more-button--dark:
hash: v1.k794b7964.774354143f7a9b7be42ded798d7dc18ecd43b5f3d9210a143b69379c6fb12e76.vw8AKSt4rudkzFXGnvjsKT1BR_7jBbnYQAHglYdYiew
components-cards-button-tile-card--with-more-button--light:
@@ -665,9 +665,9 @@ snapshots:
components-cards-text-card--edit-modal-with-agent-context--light:
hash: v1.k794b7964.4cd253abbe028273cd92dd79acfc164d6773a18013b6ed9b99e2d4051f22b654.qSa95HVltl-QyH-j6uQTVlO-bt-jn8kBT8ZGoAfgiis
components-cards-text-card--template--dark:
- hash: v1.k794b7964.8e6f24ba09b592a10e9da01c6d9e16656cf5d143d6ce27f20d14880941e1f0bf.i43yoYXm-IOhRgrQh66-5UK5DT9n1QRBEhF2hRhrE6Y
+ hash: v1.k794b7964.30f48e92f00a11e43bd1be7445ddaea744b2ee392801b48eaa07ccd731563719.s4OsZOntEBGLD_E9jfkR3W6-s6HKj7rQAcOSjfuDZ3Q
components-cards-text-card--template--light:
- hash: v1.k794b7964.0ea73d1676fdeb2712433012b37ecced0bb3dd6600ef38be24d0a5dffdf909a6.g-u7ns0GawOp2EI9wNA9dfH6OtRgIRDODBUAE3ltej0
+ hash: v1.k794b7964.84d54834545747af2ff244835b9a9f2a6ced2d835c93ab5182887e769111e83e.XMOMivXFjwOrR4qUDRvz-hxmadbNHDYXwiNTcmNu_Ns
components-cards-text-card--with-agent-context--dark:
hash: v1.k794b7964.7d35d22d06bc42d7867cf53159cf358f9a7b77ebd254de33695facc61ecc745c.up6roT9CezHOQJ8uv1xD7iTOxEEVV9DcsMjE3CXXp_M
components-cards-text-card--with-agent-context--light:
diff --git a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx
index e12e4a12ba75..63fcee74b5ac 100644
--- a/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/EditModeEdgeOverlay.test.tsx
@@ -113,14 +113,14 @@ describe('EditModeEdgeOverlay', () => {
expect(onEnterEditMode).toHaveBeenCalledWith(expect.anything(), expectedEdge)
})
- it('reveals all resize handles while any zone is hovered', () => {
+ it('reveals the bottom-right resize handle while any zone is hovered', () => {
const { container, getAllByTitle } = render(<EditModeEdgeOverlay onEnterEditMode={() => {}} />)
const zones = getAllByTitle('Drag to resize')
expect(container.querySelectorAll('.handle')).toHaveLength(0)
fireEvent.mouseEnter(zones[0])
- expect(container.querySelectorAll('.handle')).toHaveLength(8)
+ expect(container.querySelectorAll('.handle')).toHaveLength(1)
fireEvent.mouseLeave(zones[0])
expect(container.querySelectorAll('.handle')).toHaveLength(0)
@@ -134,7 +134,7 @@ describe('EditModeEdgeOverlay', () => {
fireEvent.mouseEnter(zones[0])
fireEvent.mouseEnter(zones[4])
fireEvent.mouseLeave(zones[0])
- expect(container.querySelectorAll('.handle')).toHaveLength(8)
+ expect(container.querySelectorAll('.handle')).toHaveLength(1)
})
describe('scrollbar pass-through', () => {
diff --git a/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx b/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx
index cdb9cd4a989a..54d19ecce627 100644
--- a/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx
+++ b/frontend/src/lib/components/Cards/TextCard/TextCard.test.tsx
@@ -69,18 +69,15 @@ describe('TextCard', () => {
})
describe('resize handles', () => {
- it('shows all 8 handles when showResizeHandles is true', () => {
+ it('shows only the bottom-right handle when showResizeHandles is true', () => {
const { container } = render(
<TextCard textTile={makeTextTile()} placement={DashboardPlacement.Dashboard} showResizeHandles={true} />
)
- const horizontalHandles = container.querySelectorAll('.handle.horizontal')
- const verticalHandles = container.querySelectorAll('.handle.vertical')
- const cornerHandles = container.querySelectorAll('.handle.corner')
+ const handles = container.querySelectorAll('.handle')
- expect(horizontalHandles.length).toBe(2)
- expect(verticalHandles.length).toBe(2)
- expect(cornerHandles.length).toBe(4)
+ expect(handles).toHaveLength(1)
+ expect(handles[0]).toHaveClass('corner', 'bottom-right')
})
})
})
diff --git a/frontend/src/lib/components/Cards/handles.tsx b/frontend/src/lib/components/Cards/handles.tsx
index d74051bb8959..d482c6886962 100644
--- a/frontend/src/lib/components/Cards/handles.tsx
+++ b/frontend/src/lib/components/Cards/handles.tsx
@@ -1,65 +1,22 @@
-import clsx from 'clsx'
-
-/** A one-dimensional (either horizontal or vertical) resize handle. */
-function ResizeHandle1D({
- orientation,
- className,
-}: {
- orientation: 'horizontal' | 'vertical'
- className?: string
-}): JSX.Element {
- return (
- <div className={clsx('handle', orientation, className)}>
- <svg fill="none" height="24" viewBox="0 0 16 24" width="16" xmlns="http://www.w3.org/2000/svg">
- <rect fill="var(--color-bg-surface-primary)" height="23" rx="3.5" width="15" x=".5" y=".5" />
- <g fill="var(--color-accent)">
- <rect height="2" rx=".25" width="2" x="5" y="5" />
- <rect height="2" rx=".25" width="2" x="9" y="5" />
- <rect height="2" rx=".25" width="2" x="5" y="9" />
- <rect height="2" rx=".25" width="2" x="9" y="9" />
- <rect height="2" rx=".25" width="2" x="9" y="13" />
- <rect height="2" rx=".25" width="2" x="9" y="17" />
- <rect height="2" rx=".25" width="2" x="5" y="13" />
- <rect height="2" rx=".25" width="2" x="5" y="17" />
- </g>
- <rect height="23" rx="3.5" stroke="var(--color-border-primary)" width="15" x=".5" y=".5" />
- </svg>
- </div>
- )
-}
-
-/** A two-dimensional (corner) resize handle. */
-function ResizeHandle2D({ className }: { className?: string } = {}): JSX.Element {
+export function DashboardResizeHandles(): JSX.Element {
return (
- <div className={clsx('handle', 'corner', className)}>
- <svg fill="none" height="18" viewBox="0 0 18 18" width="18" xmlns="http://www.w3.org/2000/svg">
- <rect fill="var(--color-bg-surface-primary)" height="17" rx="3.5" width="17" x=".5" y=".5" />
- <g fill="var(--color-accent)">
- <rect height="2" rx=".25" width="2" x="8" y="8" />
- <rect height="2" rx=".25" width="2" x="8" y="12" />
- <rect height="2" rx=".25" width="2" x="12" y="4" />
- <rect height="2" rx=".25" width="2" x="4" y="12" />
- <rect height="2" rx=".25" width="2" x="12" y="8" />
- <rect height="2" rx=".25" width="2" x="12" y="12" />
- </g>
- <rect height="17" rx="3.5" stroke="var(--color-border-primary)" width="17" x=".5" y=".5" />
+ <div className="handle corner bottom-right">
+ <svg
+ aria-hidden="true"
+ fill="none"
+ height="18"
+ viewBox="0 0 18 18"
+ width="18"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M3 15 15 3M9 15l6-6"
+ opacity="0.5"
+ stroke="var(--color-text-tertiary)"
+ strokeLinecap="round"
+ strokeWidth="1"
+ />
</svg>
</div>
)
}
-
-/** Standard set of dashboard resize handles: 4 edges + 4 corners. */
-export function DashboardResizeHandles(): JSX.Element {
- return (
- <>
- <ResizeHandle1D orientation="horizontal" className="top" />
- <ResizeHandle1D orientation="horizontal" className="bottom" />
- <ResizeHandle1D orientation="vertical" className="right" />
- <ResizeHandle1D orientation="vertical" className="left" />
- <ResizeHandle2D className="bottom-right" />
- <ResizeHandle2D className="bottom-left" />
- <ResizeHandle2D className="top-left" />
- <ResizeHandle2D className="top-right" />
- </>
- )
-}
diff --git a/frontend/src/scenes/dashboard/DashboardItems.scss b/frontend/src/scenes/dashboard/DashboardItems.scss
index d005a38ea61c..996a5e72af03 100644
--- a/frontend/src/scenes/dashboard/DashboardItems.scss
+++ b/frontend/src/scenes/dashboard/DashboardItems.scss
@@ -68,6 +68,10 @@
transition: none;
}
+ &.dashboard-edit-mode .react-grid-item:not(:hover, .resizing, .react-draggable-dragging) > .handle {
+ visibility: hidden;
+ }
+
&.dashboard-layout-settling .react-grid-item:not(.react-draggable-dragging, .resizing) {
transition: transform 180ms ease-out;
}
@@ -122,6 +126,16 @@
display: none;
}
+@keyframes DashboardResizeHandle__Reveal {
+ from {
+ opacity: 0;
+ }
+
+ to {
+ opacity: 1;
+ }
+}
+
.react-grid-item {
box-sizing: border-box;
transition:
@@ -143,6 +157,7 @@
align-items: flex-end;
justify-content: center;
pointer-events: none;
+ animation: DashboardResizeHandle__Reveal 300ms step-end;
&.horizontal {
svg {
@@ -188,6 +203,10 @@
transform: translate(0.5rem, 0.5rem);
}
+ &.bottom-right svg {
+ transform: translate(-0.25rem, -0.25rem);
+ }
+
&.bottom-left {
align-items: flex-end;
justify-content: flex-start;
@@ -217,6 +236,10 @@
}
}
+ &.resizing > .handle {
+ animation: none;
+ }
+
& > .react-resizable-handle {
position: absolute;
right: -0.5rem;
@@ -228,6 +251,8 @@
}
& > .react-resizable-handle.react-resizable-handle-se {
+ right: 0;
+ bottom: 0;
cursor: se-resize;
}