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.

fix(insights): stop the sample-data placeholder answering hovers (#95514)

posthog[bot]3a3064ba87b1
diff --git a/frontend/src/scenes/insights/EmptyStates/SampleDataState.scss b/frontend/src/scenes/insights/EmptyStates/SampleDataState.scss
index cf3de7e7da21..38c0618dda7a 100644
--- a/frontend/src/scenes/insights/EmptyStates/SampleDataState.scss
+++ b/frontend/src/scenes/insights/EmptyStates/SampleDataState.scss
@@ -37,13 +37,18 @@
flex-direction: column;
width: 100%;
height: 100%;
- opacity: 0;
- animation: SampleDataState__fade-up 0.7s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
+
+ // The chart is a picture of made-up data, so it answers nothing the pointer asks of it.
+ // Hover still reaches __viz, which owns the settle-to-full-opacity effect.
+ pointer-events: none;
+
+ // The hidden start comes from the keyframe plus `both`, never a declared `opacity: 0` -
+ // that would leave the placeholder invisible forever if the animation never runs
+ animation: SampleDataState__fade-up 0.7s cubic-bezier(0.25, 0.1, 0.25, 1) both;
}
&__row {
- opacity: 0;
- animation: SampleDataState__fade-up 0.5s ease-out forwards;
+ animation: SampleDataState__fade-up 0.5s ease-out both;
}
&__row-cell {
@@ -53,8 +58,7 @@
}
&__number {
- opacity: 0;
- animation: SampleDataState__fade-up 0.7s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
+ animation: SampleDataState__fade-up 0.7s cubic-bezier(0.25, 0.1, 0.25, 1) both;
}
// One-shot entrance animations complete instantly for reduced motion or screenshot tests;
diff --git a/frontend/src/scenes/insights/EmptyStates/SampleDataState.test.tsx b/frontend/src/scenes/insights/EmptyStates/SampleDataState.test.tsx
new file mode 100644
index 000000000000..ac3d83d8479a
--- /dev/null
+++ b/frontend/src/scenes/insights/EmptyStates/SampleDataState.test.tsx
@@ -0,0 +1,50 @@
+import '@testing-library/jest-dom'
+
+import { cleanup, render, waitFor } from '@testing-library/react'
+
+import { getHogChart, getHogChartTooltip, hoverAtIndex, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { SampleDataState, SampleDataVariant } from './SampleDataState'
+
+describe('<SampleDataState />', () => {
+ let cleanupJsdom: () => void
+ let cleanupRaf: () => void
+
+ beforeEach(() => {
+ initKeaTests()
+ useMocks({
+ get: {
+ '/api/projects/:projectId/tasks/': { count: 0, results: [] },
+ },
+ })
+ cleanupJsdom = setupJsdom()
+ cleanupRaf = setupSyncRaf()
+ })
+
+ afterEach(() => {
+ cleanupRaf()
+ cleanupJsdom()
+ cleanup()
+ })
+
+ it.each([
+ ['line' as SampleDataVariant, 7],
+ ['bar' as SampleDataVariant, 7],
+ ['funnel' as SampleDataVariant, 4],
+ ])('keeps the made-up %s numbers out of a tooltip on hover', async (variant, pointCount) => {
+ const { container } = render(<SampleDataState variant={variant} />)
+ const chart = getHogChart(container)
+ // Axis ticks appear once the chart commits its scales, which is also when it starts
+ // answering hovers - without waiting for them the hovers below would be dropped.
+ await waitFor(() => expect(chart.xTicks().length).toBeGreaterThan(0))
+
+ for (let index = 0; index < pointCount; index++) {
+ hoverAtIndex(chart.element, index, pointCount)
+ }
+
+ expect(getHogChartTooltip()).toBeNull()
+ })
+})
diff --git a/frontend/src/scenes/insights/EmptyStates/SampleDataState.tsx b/frontend/src/scenes/insights/EmptyStates/SampleDataState.tsx
index 599e97c998f8..440fa2733d1d 100644
--- a/frontend/src/scenes/insights/EmptyStates/SampleDataState.tsx
+++ b/frontend/src/scenes/insights/EmptyStates/SampleDataState.tsx
@@ -7,7 +7,7 @@ import { TextMorph } from 'torph/react'
import { LemonButton, LemonTag, Spinner, Tooltip } from '@posthog/lemon-ui'
import { BarChart, LineChart, PieChart } from '@posthog/quill-charts'
-import type { BarChartConfig, LineChartConfig, Series } from '@posthog/quill-charts'
+import type { BarChartConfig, LineChartConfig, PieChartConfig, Series } from '@posthog/quill-charts'
import { useChartTheme } from 'lib/charts/hooks'
import { CommandBlock } from 'lib/components/CommandBlock/CommandBlock'
@@ -42,8 +42,13 @@ const TABLE_ROWS = [
// Cycled through by the "number" variant, morphing from one to the next
const SAMPLE_NUMBERS = [1284, 1327, 1291, 1362, 1408, 1373]
-const LINE_CONFIG: LineChartConfig = { showGrid: true, showCrosshair: true }
-const BAR_CONFIG: BarChartConfig = { barCornerRadius: 2 }
+// The numbers above are invented, so nothing may read them back out. The stylesheet also makes the
+// chart ignore the pointer; turning the tooltip off here keeps that true if a layout change
+// reinstates pointer events.
+const NO_TOOLTIP = { enabled: false } as const
+const LINE_CONFIG: LineChartConfig = { showGrid: true, showCrosshair: true, tooltip: NO_TOOLTIP }
+const BAR_CONFIG: BarChartConfig = { barCornerRadius: 2, tooltip: NO_TOOLTIP }
+const PIE_CONFIG: PieChartConfig = { tooltip: NO_TOOLTIP }
function SampleNumber({ animate }: { animate: boolean }): JSX.Element {
const [valueIndex, setValueIndex] = useState(0)
@@ -119,7 +124,7 @@ function SampleChart({ variant }: { variant: Exclude<SampleDataVariant, 'number'
) : variant === 'funnel' ? (
<BarChart series={FUNNEL_SERIES} labels={FUNNEL_LABELS} theme={theme} config={BAR_CONFIG} />
) : (
- <PieChart series={PIE_SERIES} theme={theme} />
+ <PieChart series={PIE_SERIES} theme={theme} config={PIE_CONFIG} />
)}
</div>
)