: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
refactor(dashboards): reuse dashboard skeleton on shared pages (#105513)
Matt Pua43cc4123aff9
diff --git a/frontend/src/exporter/Exporter.test.tsx b/frontend/src/exporter/Exporter.test.tsxindex f11237140ce5..010afad8a06c 100644--- a/frontend/src/exporter/Exporter.test.tsx+++ b/frontend/src/exporter/Exporter.test.tsx@@ -1,5 +1,7 @@import { render } from '@testing-library/react'+import { DashboardLoadingState } from '@posthog/products-dashboards/frontend/components/DashboardLoadingState/DashboardLoadingState'+import { Exporter } from '~/exporter/Exporter'import { ExportType, ExportedData } from '~/exporter/types'import { initKeaTests } from '~/test/init'@@ -61,4 +63,11 @@ describe('Exporter (shared dashboard)', () => {// Image exports use a minimal header (h1 + description), not the Scene header with "Auto refresh every"expect(container.querySelector('.SharedDashboard-header')).toBeNull()})++ it('shows one chart placeholder per tile without dashboard controls', () => {+ const { container } = render(<DashboardLoadingState showControls={false} tileCount={3} />)++ expect(container.querySelector('[data-attr="dashboard-loading-controls"]')).toBeNull()+ expect(container.querySelectorAll('[data-attr="dashboard-loading-tile"]')).toHaveLength(3)+ })})diff --git a/frontend/src/exporter/Exporter.tsx b/frontend/src/exporter/Exporter.tsxindex 02aff16151a9..57816ff5b71f 100644--- a/frontend/src/exporter/Exporter.tsx+++ b/frontend/src/exporter/Exporter.tsx@@ -5,6 +5,8 @@ import clsx from 'clsx'import { BindLogic, useValues } from 'kea'import { Suspense, useEffect, useSyncExternalStore } from 'react'+import { DashboardLoadingState } from '@posthog/products-dashboards/frontend/components/DashboardLoadingState/DashboardLoadingState'+import { Logo } from 'lib/brand'import { useResizeObserver } from 'lib/hooks/useResizeObserver'import { useThemedHtml } from 'lib/hooks/useThemedHtml'@@ -226,7 +228,11 @@ export function Exporter(props: ExportedData): JSX.Element {/></Suspense>) : dashboard ? (- <Suspense fallback={<ExportedSceneSkeleton />}>+ <Suspense+ fallback={+ <DashboardLoadingState showControls={false} tileCount={dashboard.tiles?.length ?? 0} />+ }+ ><LazyDashboardScene dashboard={dashboard} type={type} themes={themes} /></Suspense>) : recording ? (diff --git a/products/dashboards/frontend/components/DashboardLoadingState/DashboardLoadingState.tsx b/products/dashboards/frontend/components/DashboardLoadingState/DashboardLoadingState.tsxindex 096af3dc8ff1..3fc0851bf01b 100644--- a/products/dashboards/frontend/components/DashboardLoadingState/DashboardLoadingState.tsx+++ b/products/dashboards/frontend/components/DashboardLoadingState/DashboardLoadingState.tsx@@ -1,23 +1,35 @@import { LemonSkeleton } from '@posthog/lemon-ui'-export function DashboardLoadingState(): JSX.Element {+export function DashboardLoadingState({+ showControls = true,+ tileCount = 8,+}: { showControls?: boolean; tileCount?: number } = {}): JSX.Element {return (<div className="flex flex-col gap-4" aria-label="Loading dashboard">- <div className="flex flex-wrap items-center justify-between gap-2" data-attr="dashboard-loading-controls">- <div className="flex flex-wrap items-center gap-2">- <LemonSkeleton className="h-8 w-36 rounded" />- <LemonSkeleton className="h-8 w-24 rounded" />- <LemonSkeleton className="h-8 w-20 rounded" />- <LemonSkeleton className="h-8 w-28 rounded" />- </div>- <div className="flex items-center gap-2">- <LemonSkeleton className="h-4 w-32" />- <LemonSkeleton className="h-8 w-24 rounded" />+ {showControls && (+ <div+ className="flex flex-wrap items-center justify-between gap-2"+ data-attr="dashboard-loading-controls"+ >+ <div className="flex flex-wrap items-center gap-2">+ <LemonSkeleton className="h-8 w-36 rounded" />+ <LemonSkeleton className="h-8 w-24 rounded" />+ <LemonSkeleton className="h-8 w-20 rounded" />+ <LemonSkeleton className="h-8 w-28 rounded" />+ </div>+ <div className="flex items-center gap-2">+ <LemonSkeleton className="h-4 w-32" />+ <LemonSkeleton className="h-8 w-24 rounded" />+ </div></div>- </div>+ )}<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">- {Array.from({ length: 8 }, (_, index) => (- <div key={index} className="border rounded bg-surface-primary p-4 min-h-96">+ {Array.from({ length: tileCount }, (_, index) => (+ <div+ key={index}+ className="border rounded bg-surface-primary p-4 min-h-96"+ data-attr="dashboard-loading-tile"+ ><div className="flex items-center justify-between gap-4 mb-6"><LemonSkeleton className="h-4 w-2/5" /><LemonSkeleton className="h-8 w-8 rounded" />