: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(dashboards): give dashboard name a min width and truncate descriptions (#70963)
Vasco de Krijgerb48e255aeaff
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex bde4de00e211..5a53ed9a32dc 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -5443,9 +5443,9 @@ snapshots:scenes-app-dashboards--erroring--light:hash: v1.k794b7964.5b99ae7b5f3126b06df72ccc0388ac72f1638137bb78cabeb47e9b597deb4dfc.FGPopoAtkZvSgIq_4yhg85qh1yBD3WbPV2uxNT_oK3sscenes-app-dashboards--list--dark:- hash: v1.k794b7964.7de645897fddef73f700f997c9d123281384defdef9e15be95706de9f78a4835.Nwly9RpJiN8Bfm1x5wVwSrjHnBt0vaRvHdlfk3NeL9g+ hash: v1.k794b7964.77a682a12b54c824f2105d0209088c4830b950deba55fa6c63f3d1a7ae6b12d9.GPMpy6SAAlg3ijRxYAR-Ekpum8USxQdWhP7-H8qLCx8scenes-app-dashboards--list--light:- hash: v1.k794b7964.b0342fdc7c806ec46d4005c8a7153b74986a0ce4872b164ee801b2f589e6116b.6AgAxrEUEBtn9szq4y317l28DMx9zCMkJLE1MQG2AVI+ hash: v1.k794b7964.492786d0772c83e3b11606338a691ed547b7137fffc02e9b79159dc95cc7bc18.9mQw3R7NBYWTw4lpa77ljwV28B9kFA9-39k0RFw8CeQscenes-app-dashboards--new--dark:hash: v1.k794b7964.0a812dc0a14bd20dd0b2c88701ee5ef011ced558218f55f787b73d5e6e200557.uUIqLrdSaRIgntHU8Y8ounYiTocCFv55lEntTH7iWUAscenes-app-dashboards--new--light:diff --git a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsxindex 74ca39e63fce..5fc586031d70 100644--- a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx+++ b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx@@ -64,6 +64,11 @@ export interface LemonTableProps<T extends Record<string, any>, K extends BulkSeshowHeader?: boolean/** Whether header titles should be uppercased. The default value is `true`. */uppercaseHeader?: boolean+ /**+ * Table layout algorithm. Defaults to `auto` (columns size to their content). Use `fixed` to size+ * columns from the container so wide content truncates within its cell instead of overflowing the table.+ */+ tableLayout?: 'auto' | 'fixed'/*** By default sorting goes: 0. unsorted > 1. ascending > 2. descending > GOTO 0 (loop).* With sorting cancellation disabled, GOTO 0 is replaced by GOTO 1. */@@ -127,6 +132,7 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectioexpandable,showHeader = true,uppercaseHeader = true,+ tableLayout = 'auto',noSortingCancellation: disableSortingCancellation = false,defaultSorting = null,sorting,@@ -385,7 +391,7 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectioscrollRef={scrollRef}><div className="LemonTable__content">- <table ref={tableRef}>+ <table ref={tableRef} className={tableLayout === 'fixed' ? 'table-fixed' : undefined}><colgroup>{isRowExpansionToggleShown && (diff --git a/frontend/src/lib/lemon-ui/LemonTable/LemonTableLink.tsx b/frontend/src/lib/lemon-ui/LemonTable/LemonTableLink.tsxindex 2f3d183de010..677aa6b408f6 100644--- a/frontend/src/lib/lemon-ui/LemonTable/LemonTableLink.tsx+++ b/frontend/src/lib/lemon-ui/LemonTable/LemonTableLink.tsx@@ -1,3 +1,4 @@+import clsx from 'clsx'import { ReactNode } from 'react'import { LemonMarkdown } from '../LemonMarkdown'@@ -6,29 +7,37 @@ import { Link, LinkProps } from '../Link'interface LemonTableLinkContentProps {title: JSX.Element | stringdescription?: ReactNode+ /**+ * Let the title shrink and truncate (with an ellipsis) when the cell is narrower than the content,+ * instead of overflowing. The title itself must carry a `truncate` class for the ellipsis to show.+ */+ truncateTitle?: boolean}export function LemonTableLink({title,description,+ truncateTitle,...props}: Pick<LinkProps, 'to' | 'onClick' | 'target' | 'className' | 'targetBlankIcon'> &LemonTableLinkContentProps): JSX.Element {if (!props.to) {- return <LemonTableLinkContent title={title} description={description} />+ return <LemonTableLinkContent title={title} description={description} truncateTitle={truncateTitle} />}return (- <Link subtle {...props}>- <LemonTableLinkContent title={title} description={description} />+ <Link subtle {...props} className={clsx(props.className, truncateTitle && 'block min-w-0')}>+ <LemonTableLinkContent title={title} description={description} truncateTitle={truncateTitle} /></Link>)}-function LemonTableLinkContent({ title, description }: LemonTableLinkContentProps): JSX.Element {+function LemonTableLinkContent({ title, description, truncateTitle }: LemonTableLinkContentProps): JSX.Element {return (- <div className="flex flex-col py-1">- <div className="flex flex-row items-center font-semibold text-sm gap-1">{title}</div>+ <div className={clsx('flex flex-col py-1', truncateTitle && 'min-w-0')}>+ <div className={clsx('flex flex-row items-center font-semibold text-sm gap-1', truncateTitle && 'min-w-0')}>+ {title}+ </div>{description ? (<div className="text-xs text-tertiary mt-1">diff --git a/frontend/src/scenes/dashboard/dashboards/DashboardsTable.tsx b/frontend/src/scenes/dashboard/dashboards/DashboardsTable.tsxindex c22d28fc663b..e841399b967b 100644--- a/frontend/src/scenes/dashboard/dashboards/DashboardsTable.tsx+++ b/frontend/src/scenes/dashboard/dashboards/DashboardsTable.tsx@@ -90,7 +90,8 @@ export function DashboardsTable({const columns: LemonTableColumns<DashboardType> = [{- width: 0,+ // Fixed-layout table: icon-only columns need an explicit width, otherwise they'd be squeezed to a sliver.+ width: 40,dataIndex: 'pinned',render: function Render(pinned, { id }) {return (@@ -119,32 +120,47 @@ export function DashboardsTable({AccessControlLevel.Editor)return (- <LemonTableLink- to={urls.dashboard(id)}- title={- <>- <span data-attr="dashboard-name">{name || 'Untitled'}</span>- {is_shared && (- <Tooltip title="This dashboard is shared publicly.">- <IconShare className="ml-1 text-base text-link" />- </Tooltip>- )}- {!canEditDashboard && (- <Tooltip title={DASHBOARD_CANNOT_EDIT_MESSAGE}>- <IconLock className="ml-1 text-base text-secondary" />- </Tooltip>- )}- {isPrimary && (- <Tooltip title="The primary dashboard is shown on the project home page.">- <span>- <IconHome className="ml-1 text-base text-warning" />+ // Fixed-layout table sizes this cell from the container, so the name truncates within its column+ // (full name on hover) instead of growing the cell and scrolling the whole table.+ <div className="min-w-0">+ <LemonTableLink+ to={urls.dashboard(id)}+ truncateTitle+ title={+ <>+ <Tooltip title={name || 'Untitled'}>+ <span data-attr="dashboard-name" className="truncate min-w-0">+ {name || 'Untitled'}</span></Tooltip>- )}- </>- }- description={description}- />+ {is_shared && (+ <Tooltip title="This dashboard is shared publicly.">+ <IconShare className="ml-1 text-base text-link" />+ </Tooltip>+ )}+ {!canEditDashboard && (+ <Tooltip title={DASHBOARD_CANNOT_EDIT_MESSAGE}>+ <IconLock className="ml-1 text-base text-secondary" />+ </Tooltip>+ )}+ {isPrimary && (+ <Tooltip title="The primary dashboard is shown on the project home page.">+ <span>+ <IconHome className="ml-1 text-base text-warning" />+ </span>+ </Tooltip>+ )}+ </>+ }+ description={+ description ? (+ <Tooltip title={description}>+ <span className="block truncate max-w-[30rem]">{description}</span>+ </Tooltip>+ ) : undefined+ }+ />+ </div>)},sorter: nameCompareFunction,@@ -168,7 +184,10 @@ export function DashboardsTable({const label = folder || 'Project root'return (<Tooltip title={`Filter to dashboards in ${label}`}>- <Link className="flex items-center gap-1 text-secondary" onClick={() => setFilters({ folder })}>+ <Link+ className="flex items-center gap-1 text-secondary max-w-[10rem]"+ onClick={() => setFilters({ folder })}+ ><IconFolder className="shrink-0" /><span className="truncate">{label}</span></Link>@@ -185,7 +204,8 @@ export function DashboardsTable({hideActions? {}: {- width: 0,+ // Fixed-layout table: give the actions menu a fixed width so it isn't squeezed to a sliver.+ width: 48,render: function RenderActions(_, dashboard: DashboardType) {const { id, name, user_access_level } = dashboardconst moveEntry = fsEntryFor(id)@@ -301,6 +321,7 @@ export function DashboardsTable({dataSource={dashboards as DashboardType[]}rowKey="id"rowClassName={(record) => (record._highlight ? 'highlighted' : null)}+ tableLayout="fixed"columns={columns}loading={dashboardsLoading}defaultSorting={effectiveTableSorting}