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): keep breakdown values readable in trends tooltips (#81284)

Sam Penningtoneaeccea394b9
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 1bfd70882228..f646c864ab13 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2612,6 +2612,10 @@ snapshots:
hash: v1.k794b7964.51c09169b5a57e217572bc35c0882b15252b4af936921569bf8d2a1d3a330f2f.red8aW6nElMIxDUdAHhilR3Ls2NgRChoEmFzfpGcgbU
insights-funneltrendstable--default--light:
hash: v1.k794b7964.f4486460f4481d343ecf8e0890d94f8d4c3da70164008d53bc762b6900623bc1.MRfTllR3ODYt6mNxjI-nTmfYZk0V2cXLMRmUwbKFC1Q
+ insights-insightseriestooltip--long-series-name-with-breakdown--dark:
+ hash: v1.k794b7964.199545e36ed0533f2e52b4e8a88497c4f3587208a61eb2bade6f19e09e6acb09.chYT5gr5mJZO2rmHIGW03J--hW6-dcHe9-3SSmlvfGc
+ insights-insightseriestooltip--long-series-name-with-breakdown--light:
+ hash: v1.k794b7964.7458a50ee4ac7fc39850215d33661ce955b9668aac29b58741f7972dfe97e02c.lNsTCNe5pr3yPPDVrpuuCvM02RTOqkomfXzb9jWJVdQ
insights-insightseriestooltip--multiple-formulas-with-breakdown--dark:
hash: v1.k794b7964.c2c1e9d12c2e6c27ebecdd94aaa799f9b49fd5b0f0b9e86c3ab126cab2b8ab3a.Mp3xiWvz6KnRuqNh4R3aBrrtVMdG-q0tTMyPvM4g35U
insights-insightseriestooltip--multiple-formulas-with-breakdown--light:
diff --git a/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.stories.tsx b/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.stories.tsx
index fa8898cc1a8a..d4380c796d3f 100644
--- a/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.stories.tsx
+++ b/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.stories.tsx
@@ -147,6 +147,46 @@ export const SameEventSeriesWithBreakdown: Story = {
play: async ({ canvasElement }) => await playHoverAtFraction(canvasElement, 0.5),
}
+// A long event name doesn't fit beside the breakdown value at the tooltip's max width.
+// The name truncates and the breakdown value stays readable, not the other way round.
+export const LongSeriesNameWithBreakdown: Story = {
+ render: () => (
+ <TooltipChart
+ fixtures={[
+ {
+ label: 'true',
+ data: [45, 82, 134, 210, 95],
+ event: 'subscription_renewal_reminder_delivered',
+ seriesOrder: 0,
+ breakdown_value: 'true',
+ },
+ {
+ label: 'false',
+ data: [20, 31, 46, 70, 38],
+ event: 'subscription_renewal_reminder_delivered',
+ seriesOrder: 0,
+ breakdown_value: 'false',
+ },
+ {
+ label: 'true',
+ data: [8, 12, 21, 30, 14],
+ event: 'subscription_renewal_reminder_delivered',
+ seriesOrder: 1,
+ breakdown_value: 'true',
+ },
+ {
+ label: 'false',
+ data: [2, 4, 5, 9, 3],
+ event: 'subscription_renewal_reminder_delivered',
+ seriesOrder: 1,
+ breakdown_value: 'false',
+ },
+ ]}
+ />
+ ),
+ play: async ({ canvasElement }) => await playHoverAtFraction(canvasElement, 0.5),
+}
+
// Formula series have no `action`; their `order` and `series_name` keep the repeated
// breakdown values from separate formulas attributable.
export const MultipleFormulasWithBreakdown: Story = {
diff --git a/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx b/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx
index cba382b6cb62..15e8dd8d3b52 100644
--- a/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx
+++ b/products/product_analytics/frontend/insights/shared/InsightSeriesTooltip.tsx
@@ -174,21 +174,29 @@ export function SeriesLabel({
const seriesPrefix =
seriesIdentification !== 'none' ? (
- <span className="opacity-50 shrink-0 inline-flex items-center">
+ <>
{seriesLetter}
- <span>
+ {/* The name is the same on every row, so it gives up space first — the breakdown
+ value is what tells the rows apart, and a long event name would otherwise
+ truncate it away. The letter and the separator stay put. */}
+ <span className="opacity-50 truncate min-w-0 shrink">
{(datum.action ? getDisplayNameFromEntityFilter(datum.action) : datum.series_name) ?? datum.label}
- &nbsp;·&nbsp;
</span>
- </span>
+ <span className="opacity-50 shrink-0">&nbsp;·&nbsp;</span>
+ </>
) : null
- // inline-flex: breakdown span truncates (flex-1), period label stays visible (shrink-0).
+ // Three levels of priority, in order: the period label never shrinks, the breakdown value
+ // shrinks only once the row runs out of name, and the name absorbs everything before that.
+ // The breakdown and the period share a shrink-0 group so shrinking is sequential — a group
+ // that shrinks proportionally costs a short value two characters to the ellipsis.
return (
<span className="inline-flex items-center w-full overflow-hidden">
{seriesPrefix}
- <span className="truncate min-w-0 flex-1">{breakdownTitle ?? datum.label}</span>
- {comparePeriod && <span className="shrink-0 opacity-60">&nbsp;·&nbsp;{comparePeriod}</span>}
+ <span className="inline-flex items-center min-w-0 shrink-0 max-w-full">
+ <span className="truncate min-w-0 shrink">{breakdownTitle ?? datum.label}</span>
+ {comparePeriod && <span className="shrink-0 opacity-60">&nbsp;·&nbsp;{comparePeriod}</span>}
+ </span>
</span>
)
}