: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): show tooltip with full header name when truncated (#73121)
Xandera44185cef3be
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Table.tsxindex b8546e8805ce..a86acccf3818 100644--- a/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx+++ b/frontend/src/queries/nodes/DataVisualization/Components/Table.tsx@@ -2,7 +2,7 @@ import '../../DataTable/DataTable.scss'import { useActions, useValues } from 'kea'import posthog from 'posthog-js'-import React from 'react'+import React, { useCallback, useLayoutEffect, useRef, useState } from 'react'import { IconPin, IconPinFilled } from '@posthog/icons'import { LemonBanner, LemonTable, LemonTableColumn, Tooltip } from '@posthog/lemon-ui'@@ -107,6 +107,47 @@ function getCellTitle(cell: TableDataCell<any>): string | undefined {return undefined}+// Header labels are clamped to a few lines with a CSS ellipsis when they don't fit. The full text stays+// in the DOM, so we compare the rendered box against the content and reveal the full name on hover only+// when it's actually cut off. The tooltip prefers the explicit label but falls back to the rendered text,+// so titles rendered from JSX (e.g. a human-readable property name) show their label, not a raw column key.+function ColumnHeaderTitle({+ formattedTitle,+ fullTitle,+ children,+}: {+ formattedTitle: React.ReactNode+ fullTitle?: string+ children?: React.ReactNode+}): JSX.Element {+ const titleRef = useRef<HTMLSpanElement>(null)+ const [tooltip, setTooltip] = useState<string | undefined>(undefined)++ const detectTruncation = useCallback((): void => {+ const el = titleRef.current+ if (!el) {+ return+ }+ const isTruncated = el.scrollHeight - el.clientHeight > 1 || el.scrollWidth - el.clientWidth > 1+ setTooltip(isTruncated ? fullTitle || el.textContent || undefined : undefined)+ }, [fullTitle])++ useLayoutEffect(() => {+ detectTruncation()+ }, [detectTruncation])++ return (+ <div className="flex items-center gap-1">+ <Tooltip title={tooltip}>+ <span ref={titleRef} onMouseEnter={detectTruncation}>+ {formattedTitle}+ </span>+ </Tooltip>+ {children}+ </div>+ )+}+export const Table = (props: TableProps): JSX.Element => {const { isDarkModeOn } = useValues(themeLogic)@@ -135,6 +176,7 @@ export const Table = (props: TableProps): JSX.Element => {const { title, ...columnMeta } = renderColumnMeta(column.name, props.query, props.context)const columnTitle = settings?.display?.label || title || column.nameconst formattedTitle = typeof columnTitle === 'string' ? formatColumnTitle(columnTitle) : columnTitle+ const fullColumnTitle = typeof columnTitle === 'string' ? columnTitle : undefinedconst computeConditionalFormattingBackground = (data: TableDataCell<any>[]): string | undefined => {const cell = data[index]@@ -211,8 +253,7 @@ export const Table = (props: TableProps): JSX.Element => {// (rows become the original columns), so only offer it in the normal orientation.sorter: isTransposed ? undefined : (a, b) => compareTableCells(a[index], b[index]),title: (- <div className="flex items-center gap-1">- <span>{formattedTitle}</span>+ <ColumnHeaderTitle formattedTitle={formattedTitle} fullTitle={fullColumnTitle}>{isPinningEnabled && (<Tooltip title={isColumnPinned(column.name) ? 'Unpin column' : 'Pin column'}><span@@ -230,7 +271,7 @@ export const Table = (props: TableProps): JSX.Element => {</span></Tooltip>)}- </div>+ </ColumnHeaderTitle>),render: (_, data, recordIndex: number, rowCount: number) => {const cell = data[index]