: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
fix(insights): clip lemon table cells instead of overflowing neighbours (#69055)
Sam Penningtone98012f93df1
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 94a8f2cac306..7f19e6d8b416 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -2632,6 +2632,10 @@ snapshots:hash: v1.k794b7964.8149c232d7b3c8ee1abb048003a5c9434dba8186bc728da5da4b9af2dca16cd0.NQh23-oNGsHd14_4QI2tUt0IRbdnHKUpmgDBuo-1x1Ainsights-insightstable--is-legend--light:hash: v1.k794b7964.d8663c41468bfaac7bff46419f17906bb57a3ea4a92036d3f2901f2bd5a645ef.mj8iZ-ckvyoJVUPIB6QGatB5oqSb2S5aLPbYuCi9nb0+ insights-insightstable--sql-breakdown--dark:+ hash: v1.k794b7964.cc64ca6ab10ef0f936dd479fb6a76716fd5935b3dee59833377c03cb3e36569a.kVka0mzCaVBMto0uHpEx5cTwdVDK0wlESIquSCaBrjk+ insights-insightstable--sql-breakdown--light:+ hash: v1.k794b7964.710a5fa22da7eff24e97e754426977214d9cdb9fd0252415534110bc7d9bbf95.EmqhUt-YOAWJV1nbFZ2BA-Let9QcaeDgslu9bcPR_mEinsights-retentionbarchart--default--dark:hash: v1.k794b7964.a0a62c755e4912e9647dcacccd61ec1adfeeb59141bd64a6f56d8b281a7ef692.XEvkHq7PlOlPDZFJW2PIrqN2QcvVpd1vk6sVLG4DTFsinsights-retentionbarchart--default--light:diff --git a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsxindex 94ecc0ab958a..3276e0c36753 100644--- a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx+++ b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx@@ -451,6 +451,10 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectio)const { isSticky: isPinned, leftPosition } = stickyInfo+ // Truncate only when a max width is set and the column isn't sized by its author.+ const truncateHeader =+ !!maxHeaderWidth && !column.width && !column.fullWidth+return (<thkey={`LemonTable-th-${columnGroupIndex}-${columnKey}`}@@ -519,12 +523,15 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectio<divclassName={clsx('flex items-center',+ // Clip at maxWidth: sticky headers keep `overflow: visible` on the th, so+ // without this an over-wide title spills across the neighbouring headers+ truncateHeader && 'overflow-hidden',column?.fullWidth && 'w-full',column.sorter && 'cursor-pointer')}/* eslint-disable-next-line react/forbid-dom-props */style={- maxHeaderWidth+ truncateHeader? { maxWidth: maxHeaderWidth }: undefined}@@ -536,6 +543,14 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectio<IconInfo className="ml-1 text-base" /></div></Tooltip>+ ) : truncateHeader &&+ typeof column.title === 'string' ? (+ <div+ className="min-w-0 truncate"+ title={column.title}+ >+ {column.title}+ </div>) : (column.title)}diff --git a/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.stories.tsx b/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.stories.tsxindex 2a3d68f7f84b..b7f9c47da517 100644--- a/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.stories.tsx+++ b/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.stories.tsx@@ -161,3 +161,66 @@ export const ComparePrevious: Story = {isMainInsightView: true,},}++// A HogQL breakdown expression that is far too long to fit in a column. The header should be clipped+// with an ellipsis rather than overflowing into neighbouring columns.+const LONG_SQL_BREAKDOWN =+ "concat(toString(properties.$browser), ' - ', toString(properties.$os), ' - ', toString(properties.$device_type), ' - ', toString(properties.$geoip_country_name))"++const LONG_BREAKDOWN_VALUES = [+ 'Google Chrome - Mac OS X - Desktop - United States of America',+ 'Mozilla Firefox - Windows - Desktop - United Kingdom of Great Britain and Northern Ireland',+ 'Safari - iOS - Mobile - Federated States of Micronesia',+ 'Microsoft Edge - Windows - Desktop - United Republic of Tanzania',+]++const renderSqlBreakdownInsightsTable = (props: any): JSX.Element => {+ const [dashboardItemId] = useState(() => `InsightTableStory.${uniqueNode++}`)++ // eslint-disable-next-line @typescript-eslint/no-var-requires+ const insight = __trendsLineBreakdown as any++ // Give each result a long, compound breakdown value too+ const result = insight.result+ .slice(0, LONG_BREAKDOWN_VALUES.length)+ .map((r: Record<string, any>, index: number) => ({+ ...r,+ breakdown_value: LONG_BREAKDOWN_VALUES[index],+ label: `$pageview - ${LONG_BREAKDOWN_VALUES[index]}`,+ }))++ const cachedInsight = {+ ...insight,+ short_id: dashboardItemId,+ result,+ query: {+ ...insight.query,+ source: {+ ...insight.query.source,+ breakdownFilter: { breakdown: LONG_SQL_BREAKDOWN, breakdown_type: 'hogql' },+ },+ },+ }++ const insightProps = { dashboardItemId, doNotLoad: true, cachedInsight } as InsightLogicProps++ const dataNodeLogicProps: DataNodeLogicProps = {+ query: cachedInsight.query.source,+ key: insightVizDataNodeKey(insightProps),+ cachedResults: getCachedResults(cachedInsight, cachedInsight.query.source),+ doNotLoad: insightProps.doNotLoad,+ }++ return (+ <BindLogic logic={insightLogic} props={insightProps}>+ <BindLogic logic={dataNodeLogic} props={dataNodeLogicProps}>+ <InsightsTable {...props} />+ </BindLogic>+ </BindLogic>+ )+}++export const SqlBreakdown: Story = {+ render: renderSqlBreakdownInsightsTable,+ args: {},+}diff --git a/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.tsx b/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.tsxindex d5da974dadf9..2c92087fae84 100644--- a/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.tsx+++ b/frontend/src/scenes/insights/views/InsightsTable/InsightsTable.tsx@@ -154,7 +154,7 @@ export function InsightsTable({columns.push({title: (- <div className="flex items-center gap-4">+ <div className="flex items-center gap-4 min-w-0">{hasCheckboxes && (<SeriesCheckColumnTitleindexedResults={indexedResults}