: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
perf(dashboards): stop every tile re-rendering on unrelated state changes (#125689)
Matt Pua636c1945f547
diff --git a/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.test.ts b/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.test.tsindex 2134d9a7612d..f09cd75572bc 100644--- a/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.test.ts+++ b/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.test.ts@@ -1,3 +1,4 @@+import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'import { dashboardWidgetMenusLogic } from 'lib/components/Cards/InsightCard/dashboardWidgetMenusLogic'@@ -29,6 +30,18 @@ describe('dashboardWidgetMenusLogic', () => {})})+ it('keeps copyToDestinations stable when a caller passes a new empty tiles array', () => {+ const logic = dashboardWidgetMenusLogic({ instanceKey: 'test', dashboardId: 1, dashboard_tiles: [] })+ logic.mount()+ const destinations = logic.values.copyToDestinations++ dashboardWidgetMenusLogic({ instanceKey: 'test', dashboardId: 1, dashboard_tiles: [] })+ // The selectors recompute only when the store state changes, and any action does that in the app.+ router.actions.push('/elsewhere')++ expect(logic.values.copyToDestinations).toBe(destinations)+ })+it('copyToDestinations excludes the current dashboard and disables rows already placed', async () => {dashboardsModel.actions.addDashboardSuccess({id: 1,diff --git a/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.ts b/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.tsindex 2751129e7426..383ce71af3f2 100644--- a/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.ts+++ b/frontend/src/lib/components/Cards/InsightCard/dashboardWidgetMenusLogic.ts@@ -1,6 +1,7 @@import { MakeLogicType, connect, kea, key, path, props, selectors } from 'kea'import { accessLevelSatisfied } from 'lib/utils/accessControlUtils'+import { objectsEqual } from 'lib/utils/objects'import { liveDashboardIds } from 'scenes/dashboard/liveDashboardIds'import { dashboardsModel } from '~/models/dashboardsModel'@@ -74,6 +75,7 @@ export const dashboardWidgetMenusLogic = kea<dashboardWidgetMenusLogicType>([}return set},+ { resultEqualityCheck: objectsEqual },],/** Destinations for Copy to and Move to submenus (disabled rows explain why a target is unavailable). */copyToDestinations: [diff --git a/frontend/src/scenes/dashboard/DashboardItems.tsx b/frontend/src/scenes/dashboard/DashboardItems.tsxindex 2711dcd45715..becd61ec3647 100644--- a/frontend/src/scenes/dashboard/DashboardItems.tsx+++ b/frontend/src/scenes/dashboard/DashboardItems.tsx@@ -543,7 +543,7 @@ export function DashboardItems({ showCreateAnomalyAlertButton }: DashboardItemsPif (dashboard?.id) {reportDashboardTileRepositioned(dashboard.id, 'resized', effectiveZoom)}- }, [dashboard?.id, reportDashboardTileRepositioned, effectiveZoom, flushPendingLayouts])+ }, [dashboard?.id, effectiveZoom, flushPendingLayouts])const handleDragStart = useCallback((@@ -598,14 +598,7 @@ export function DashboardItems({ showCreateAnomalyAlertButton }: DashboardItemsPreportDashboardTileRepositioned(dashboard.id, 'moved', effectiveZoom)}},- [- dashboard?.id,- reportDashboardTileRepositioned,- effectiveZoom,- flushPendingLayouts,- finishTileDrag,- stopAutoScroll,- ]+ [dashboard?.id, effectiveZoom, flushPendingLayouts, finishTileDrag, stopAutoScroll])const renderTile = (tile: DashboardTile): JSX.Element | undefined => {