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.

feat(customer-analytics): resize account list columns (#91908)

Arthur Moreira de Deus7c088c69237f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index de63cf19d27d..44d2f8c0c3c4 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -4464,6 +4464,10 @@ snapshots:
hash: v1.k794b7964.dfefa5e13670c4ff661314dbad8f57e75b257586b0e6343293b48e5ad65160ce.lVRReftWOc1bwJ44LsxxwJAlQmywpsft-RAaupLvgLg
lemon-ui-lemon-table--with-mandatory-sorting--light:
hash: v1.k794b7964.50be4384d7a67308b28bd740d1e84347fe4b471eaf03a2bc3ea52c840255de91.gLmHFSKz9ruru1cWO0PIyhFJdPojiPF4aqpyCDEDihY
+ lemon-ui-lemon-table--with-resizable-columns--dark:
+ hash: v1.k794b7964.54ad02003e46c769c1a4922b18ecc52df3d26d2f9e275c5e2754f22998306393.DZzLC997g28Q_2trYwyrvGRGg8AH8SBeROXMllqmIE8
+ lemon-ui-lemon-table--with-resizable-columns--light:
+ hash: v1.k794b7964.54aa0c1313dd591719f5c0331638101ee99487143c2b71e62c6f4612dfc5555e.dAPm8Ua9mRunaLEPuaIXPDuQqkl3u8F9GLPHKfpFhds
lemon-ui-lemon-table--with-row-actions--dark:
hash: v1.k794b7964.1bd19ec7e185db60fad4f360b831a15233afc37b27dba90b47fcf029139369eb.XGFyuA7rFcNPBpu5h8CXQEo25X9V6FJkl2HJ2JMoArY
lemon-ui-lemon-table--with-row-actions--light:
@@ -6049,41 +6053,41 @@ snapshots:
scenes-app-batchexports--runs-with-data--light:
hash: v1.k794b7964.4c1646577dc53efffd814b1a2e723f9da6b10d3641e979f48c5d0447859e2348.fkHuUw1l_9c3rJKSi467jx-6Nv81nNp-PjeRmsgU7l0
scenes-app-customer-analytics-accounts--default--dark:
- hash: v1.k794b7964.5029cc9636cf8a1e93b707e9d48d905b30662613b481927d0cb56d546dc10317.VZw3U--3gG98gmwGFU0AFNw2XsDFWKQD5KIfMq2y-p8
+ hash: v1.k794b7964.dbaff4c177f276bb47e0587c5f66195cec454a062fa87a2c506ad1cbc5d04a40.3YhGb7YnUDZDgX333J4grk5qzIg-8A1qMdTDxUiTLec
scenes-app-customer-analytics-accounts--default--light:
- hash: v1.k794b7964.a6e69d146704a3f3a20505299fbae7d8f43e4f5a4747e9f11f6503cb0d456706.yHgdwBuqrbDdiWI1YHHNt8Zr43DwZ4nKhUjal7A8KVM
+ hash: v1.k794b7964.c9ec4f78a9fa7101e014af8c25168fb12ea7f9c6f9ff9c1f7023c2500a1b17c8.FOaZdKiATjm-L6s6qpyNzZlKcVNr35awJg9y53N9v4g
scenes-app-customer-analytics-accounts--empty--dark:
- hash: v1.k794b7964.d5cb3b149fb59116acfcf317da2d09c92f5ea04343c1573380f7470e1102293d._xJcGDJwr0jVFV1gRN3XL1aISaN1AURfT_GePQ4aXBo
+ hash: v1.k794b7964.476e882b10a17c95583186080ee4278caccc81741c79dd5e00b9bbf978034137.PJGrQRo3GFGiE8PPimhZtLGF8JUXA_neVBrZ631auLM
scenes-app-customer-analytics-accounts--empty--light:
- hash: v1.k794b7964.05948f6f2364874e0636e340a4b6c5356c63fa3f8968aa42c694d706d2b91876.yOkLiE5so_xwbPJnuckUsEwHPuIuFEL3vh3xmzUdyaE
+ hash: v1.k794b7964.b5b8140f271f4e6da493124f472b38ae6f136fe20e2b58661869fe05c6cf7464.9E-nJaqW5RSGIeB7bwdTn2AJMsfhaQzFKdcRLkPswoc
scenes-app-customer-analytics-accounts--feature-gate-off--dark:
hash: v1.k794b7964.4b8d5226ee154debdf333ff93d65a90ca766bcb25951e1baf36affb8b84b548d.dWZSHssPc83RkHVE-JPJA562bJR7MUim2yfqhjfNE50
scenes-app-customer-analytics-accounts--feature-gate-off--light:
hash: v1.k794b7964.e8b91bf6a0dd1b5d31064f4cbb94e9791e999c210831c455a498d0c7cc7e6bbb.IkZPJrJz33sKS8zzKwoy8V3s0GvmKpe5EGYTCIljhLs
scenes-app-customer-analytics-accounts--row-expanded-conversations--dark:
- hash: v1.k794b7964.6ae47bc00326e5b1f9e1dfef13182cad9becfc989f2507d5b2d225d317847e45.1HnLBIw57ILVXFcmDVI1W3JYwbhnga_MYTjwVyVBx34
+ hash: v1.k794b7964.bc44c4751057dc02225b68a4346ab8b3de201c9fc0753ae3343c9155c11d7d7c.7rkYDKhJNy6YMfcm4t5bgSOKJIzmsU5YfufOKgfvBcQ
scenes-app-customer-analytics-accounts--row-expanded-conversations--light:
- hash: v1.k794b7964.3e4daf872eb81f88fbbf8809a32c5d62ec190b9751b4c200dc03d0f47238c64b.2_R_yhblfgfj3v92VWL5V9j9i03ZsKial9L-DO3YL6s
+ hash: v1.k794b7964.1c90a60a6f06c07f82bfe0a83877eeff9ba5eeafa3ad9d7cfb403df7495d6bdf.y4eZZzVpCP6q_c2kMHVAB7RsByV7ITi5x4y3LhV8e9k
scenes-app-customer-analytics-accounts--row-expanded-empty--dark:
- hash: v1.k794b7964.64c6a97719eac3694328d10e98e08b7fab6efb7ce58e32bc891c5c875491009f.qkTtsSosk3TlRtMfGCAJ-uadqBXTMgS4PXKWVTbc-mM
+ hash: v1.k794b7964.8d9465c3188fab66f5b2ea033dc1d6668bd5de795b8811e99fca09de839f4896.4IHVJmASpKvBBlqeOgzD9RPPqmuO0a30CyzeiQYfg50
scenes-app-customer-analytics-accounts--row-expanded-empty--light:
- hash: v1.k794b7964.711908526edcaa97feeba398ed8acd1fc433f59b91147ee5622baf333a8b0387.4zfYB2NnD0ezvuJ0cdbFkTwh7-mBuVvcbypPaYzXJvg
+ hash: v1.k794b7964.e5df21b2dfc2524f2456e2452cacc0086d1ac3605fe7a36de5cdb4940b4ca11d.fqwdsEPpn_LPQYC5w0Oh5W_1o3w85VjWslOSIsr7ASw
scenes-app-customer-analytics-accounts--row-expanded-feature-requests--dark:
- hash: v1.k794b7964.ee4d66f4cf3a0774cb7f5f190f8763daad66096461c047fd14dd1feb9bb9fe47.wjaeSgN4fZB7YP6VYHbH_1s3GkpXkZdtiI6hE_57D9o
+ hash: v1.k794b7964.cb06da092218f23ea59f7343e56b659cb9628b05a73f90a6a23676291a63a308.uTWz6x-QW1dWdZN-YdmPXRI0oE-1DogVYcge2yCGK6U
scenes-app-customer-analytics-accounts--row-expanded-feature-requests--light:
- hash: v1.k794b7964.6db810d612de656d8e16ef2fa28601e2adeaee561be28226ed5848f4c947b56f.MBjkBaRfn3pDvYzb5hO1yUorHjMQmWVh27V-Nr4WCq0
+ hash: v1.k794b7964.f0f0578420641a90e8f695fcf722c1a019f95e1a0abbf6720388332363b7e070.5KgxFIYNv58VzKghCJWXqB1De23EHUKikGVjnA_3Uf8
scenes-app-customer-analytics-accounts--row-expanded-links-disabled--dark:
- hash: v1.k794b7964.d7c0995e7588ede95f66f7235d94a3f6f0d73306f1a27cfe3a91845fc76e9bd8.SgPuM2YRTP9H2lX07PuntHqO12du3Fdtv3yYFEwLySE
+ hash: v1.k794b7964.b18c0d31c49773263d715ad6484593c0de8d724e932c8f0bd21fceb1000c3ec3.CM4Zw-HP7kOfH-i6R1zPPk_Ncb4yQfMj9aXDxxpGDE8
scenes-app-customer-analytics-accounts--row-expanded-links-disabled--light:
- hash: v1.k794b7964.2a29bb01d732bb6328279c9c987264c3078a413d735cdff248c0f959695c7c64.W3o2IkXVgAnetRbVA4iHULghtZGBps1dlYtDS-OmLWY
+ hash: v1.k794b7964.9386895c47574e53cb68bc8ae7f1719a39adf30da685de1a739187eaf1320f6c.GV9GJja8R_rTkrScMHgG0so-41JMELpSr17GwcIaNys
scenes-app-customer-analytics-accounts--row-expanded-usage-not-found--dark:
- hash: v1.k794b7964.7f047195753fa396612db252f801d05b1c1f0092a9b6c05f5ad955db9ca3f719.GkW15w-pinFn2gQlWyqlggJIGMHlIgK3Ke1K6ETIVa0
+ hash: v1.k794b7964.fe7e23195dccbfa191e8f7b5f04fffbe19de72ae341370782776b72acd28230e.LP13YCcQAZ9pRgAE8nsq7HgAe5CYXfxoDgczD8TsmHU
scenes-app-customer-analytics-accounts--row-expanded-usage-not-found--light:
- hash: v1.k794b7964.074c9d6046ed7e22cfff1c0c18ebffdb385feaf292db3d988097875d9e33ba5d.GuicCf-sDnbmmfufgRnrJNqAQVVpy9vGEhk1WvG6l7s
+ hash: v1.k794b7964.771b34831c25ea548ee80ab2d6a8207754ea8ed7105c18515afa76db88e2c000.SFNWruc03ghKq3EoRc06R-qLvwj9h-6O69OYGmNWkG8
scenes-app-customer-analytics-accounts--row-expanded-with-note--dark:
- hash: v1.k794b7964.fe81f917cde0cd236fdc089c4f199bf47e857f460034a4c4bcbe9aa66a414dfe.WtPEGr3dP6WOiXPqTlvuOu6GB0L7uExwtuVAaADo_qU
+ hash: v1.k794b7964.05713b54ad9cf3836789543e3a5f87dca1e1d0e669ab34f62366ba28f7d3cca1.sa1189qTJs0JIycSx9L-7SMT-ZRyFbk0zdRVmsz2P24
scenes-app-customer-analytics-accounts--row-expanded-with-note--light:
- hash: v1.k794b7964.74290c56ba027ddda9acd7151eddd87dddeb8c23dd62de38090c80849982f8a9.Ro118m45cILMTdu2kf1TXFDbKpa_UjNizxLkM71jzIQ
+ hash: v1.k794b7964.be9cb6321f85a9a345a43097044f167d0c1af73b32239d381e981e63d00f0bd2.juVLg0CcEGHNdX6BuKTCvZMSMP200h_yudnSK8x89EY
scenes-app-customer-analytics-dashboard--b-2-b-mode-with-groups-enabled--dark:
hash: v1.k794b7964.cf03f6a65f846aec287042028193b834c567f01226d2e91f6389df5af935530d.bXzRv9MkU0nXN-4tvGbenagVaJuhFr86goke8HVYFJY
scenes-app-customer-analytics-dashboard--b-2-b-mode-with-groups-enabled--light:
diff --git a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.scss b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.scss
index 36c19f1e4f62..720a44c89840 100644
--- a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.scss
+++ b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.scss
@@ -1,3 +1,8 @@
+body.is-resizing-column {
+ cursor: col-resize !important;
+ user-select: none;
+}
+
@keyframes LemonTable__row__highlight__animation {
0% {
background-color: var(--color-accent-highlight-secondary);
diff --git a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.stories.tsx b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.stories.tsx
index f6e1397cd7fa..fea0b92df497 100644
--- a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.stories.tsx
+++ b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.stories.tsx
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from '@storybook/react'
+import { useState } from 'react'
import { IconTrash } from '@posthog/icons'
@@ -10,7 +11,7 @@ import { More } from '../LemonButton/More'
import { LemonDivider } from '../LemonDivider'
import { LemonTable, LemonTableProps } from './LemonTable'
import { LemonTableLink } from './LemonTableLink'
-import { LemonTableColumns } from './types'
+import type { LemonTableColumn, LemonTableColumns } from './types'
type Story = StoryObj<LemonTableProps<any>>
const meta: Meta<LemonTableProps<any>> = {
@@ -45,7 +46,7 @@ const MANY_PEOPLE: MockPerson[] = [
{ name: 'Ingrid S.', occupation: 'Writer' },
]
-const WIDE_COLUMNS: LemonTableColumns<MockPerson> = [
+const WIDE_COLUMNS: LemonTableColumn<MockPerson, keyof MockPerson | undefined>[] = [
{
title: 'Name',
dataIndex: 'name',
@@ -485,6 +486,26 @@ export const WithRowActions: Story = {
},
}
+function ResizableColumnsTable(): JSX.Element {
+ const [widths, setWidths] = useState<Record<number, number>>({})
+
+ return (
+ <LemonTable
+ columns={WIDE_COLUMNS.slice(0, 3).map((column, index) => ({
+ ...column,
+ width: widths[index] ?? column.width,
+ resizable: true,
+ onResize: (width: number) => setWidths((currentWidths) => ({ ...currentWidths, [index]: width })),
+ }))}
+ dataSource={MANY_PEOPLE.slice(0, 5)}
+ />
+ )
+}
+
+export const WithResizableColumns: Story = {
+ render: () => <ResizableColumnsTable />,
+}
+
export const WithHorizontalOverflow: Story = {
render: () => {
return (
diff --git a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.test.tsx b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.test.tsx
index 8029461b5b64..96044d60a66f 100644
--- a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.test.tsx
+++ b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.test.tsx
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom'
-import { cleanup, render, screen } from '@testing-library/react'
+import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { router } from 'kea-router'
import { initKeaTests } from '~/test/init'
@@ -53,6 +53,52 @@ describe('LemonTable', () => {
expect(renderedOrder()).toEqual(expectedOrder)
})
+ it('resizes columns and locks sibling widths', () => {
+ const onResize = jest.fn()
+ const onSecondColumnResize = jest.fn()
+ const onResizeEnd = jest.fn()
+ render(
+ <LemonTable
+ rowKey="id"
+ dataSource={DATA}
+ columns={[
+ {
+ title: 'Value',
+ key: 'value',
+ dataIndex: 'value',
+ resizable: true,
+ onResize,
+ onResizeEnd,
+ },
+ {
+ title: 'Name',
+ key: 'name',
+ dataIndex: 'name',
+ resizable: true,
+ onResize: onSecondColumnResize,
+ },
+ ]}
+ />
+ )
+ jest.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(
+ function (this: HTMLElement): DOMRect {
+ return { width: this.textContent === 'Value' ? 150 : 100 } as DOMRect
+ }
+ )
+ jest.spyOn(window, 'requestAnimationFrame').mockImplementation((callback: FrameRequestCallback) => {
+ callback(0)
+ return 1
+ })
+
+ fireEvent.mouseDown(screen.getAllByLabelText('Resize column')[0], { button: 0, clientX: 100 })
+ fireEvent.mouseMove(window, { clientX: 175 })
+ fireEvent.mouseUp(window)
+
+ expect(onResize).toHaveBeenLastCalledWith(225)
+ expect(onSecondColumnResize).toHaveBeenCalledWith(100)
+ expect(onResizeEnd).toHaveBeenCalledTimes(1)
+ })
+
it('keeps headers, expanded rows, and empty states aligned when the row expansion toggle is hidden', () => {
const { rerender } = render(
<LemonTable
diff --git a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx
index 6204904c2c27..8c90a2c9293d 100644
--- a/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx
+++ b/frontend/src/lib/lemon-ui/LemonTable/LemonTable.tsx
@@ -21,6 +21,7 @@ import { BulkSelectionBar } from './BulkSelectionBar'
import { determineColumnKey, getStickyColumnInfo } from './columnLayoutUtils'
import { LemonTableLoader } from './LemonTableLoader'
import { Sorting, SortingIndicator, getNextSorting } from './sorting'
+import { TableColumnResizeHandle } from './TableColumnResizeHandle'
import { TableRow } from './TableRow'
import { ExpandableConfig, LemonTableColumn, LemonTableColumnGroup, LemonTableColumns } from './types'
import { BulkSelectionConfig, BulkSelectionKey, useBulkSelection } from './useBulkSelection'
@@ -94,6 +95,7 @@ export interface LemonTableProps<T extends Record<string, any>, K extends BulkSe
nouns?: [string, string]
className?: string
style?: React.CSSProperties
+ tableStyle?: React.CSSProperties
'data-attr'?: string
/** Footer to be shown below the table. */
footer?: React.ReactNode
@@ -149,6 +151,7 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectio
nouns = ['entry', 'entries'],
className,
style,
+ tableStyle,
'data-attr': dataAttr,
footer,
firstColumnSticky,
@@ -367,6 +370,21 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectio
}
const isRowExpansionToggleShown = expandable ? (expandable?.showRowExpansionToggle ?? true) : false
+ const preserveResizableColumnWidths = (header: HTMLTableCellElement): void => {
+ const headerOffset = Number(isRowExpansionToggleShown)
+ const headerCells = header.parentElement?.children
+ if (!headerCells) {
+ return
+ }
+ columns
+ .filter((column) => !column.isHidden)
+ .forEach((column, index) => {
+ const width = headerCells[index + headerOffset]?.getBoundingClientRect().width
+ if (column.resizable && column.onResize && width) {
+ column.onResize(width)
+ }
+ })
+ }
const visibleDataColumnCount = useMemo(() => columns.filter((column) => !column.isHidden).length, [columns])
// Matches the main header row cell count so the loader row does not add an extra table column (which shifts headers while loading)
@@ -402,7 +420,11 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectio
scrollRef={scrollRef}
>
<div className="LemonTable__content">
- <table ref={tableRef} className={tableLayout === 'fixed' ? 'table-fixed' : undefined}>
+ <table
+ ref={tableRef}
+ className={tableLayout === 'fixed' ? 'table-fixed' : undefined}
+ style={tableStyle}
+ >
<colgroup>
{
isRowExpansionToggleShown && (
@@ -489,6 +511,7 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectio
'LemonTable__header',
column.sorter && 'LemonTable__header--actionable',
columnIndex === 0 && 'LemonTable__boundary',
+ column.resizable && 'relative',
firstColumnSticky &&
columnGroupIndex === 0 &&
columnIndex === 0 &&
@@ -661,6 +684,13 @@ export function LemonTable<T extends Record<string, any>, K extends BulkSelectio
/>
))}
</div>
+ {column.resizable && column.onResize ? (
+ <TableColumnResizeHandle
+ onResize={column.onResize}
+ onResizeStart={preserveResizableColumnWidths}
+ onResizeEnd={column.onResizeEnd}
+ />
+ ) : null}
</th>
)
})
diff --git a/frontend/src/lib/lemon-ui/LemonTable/TableColumnResizeHandle.tsx b/frontend/src/lib/lemon-ui/LemonTable/TableColumnResizeHandle.tsx
new file mode 100644
index 000000000000..3b32cab8ac99
--- /dev/null
+++ b/frontend/src/lib/lemon-ui/LemonTable/TableColumnResizeHandle.tsx
@@ -0,0 +1,87 @@
+import { useEffect, useRef } from 'react'
+import type { MouseEvent as ReactMouseEvent } from 'react'
+
+const MIN_COLUMN_WIDTH = 80
+const MAX_COLUMN_WIDTH = 1000
+interface TableColumnResizeHandleProps {
+ onResize: (width: number) => void
+ onResizeStart?: (header: HTMLTableCellElement) => void
+ onResizeEnd?: () => void
+}
+
+export function TableColumnResizeHandle({
+ onResize,
+ onResizeStart,
+ onResizeEnd,
+}: TableColumnResizeHandleProps): JSX.Element {
+ const cleanupResizeRef = useRef<(() => void) | null>(null)
+
+ useEffect(
+ () => () => {
+ cleanupResizeRef.current?.()
+ },
+ []
+ )
+
+ const startResize = (event: ReactMouseEvent<HTMLButtonElement>): void => {
+ if (event.button !== 0) {
+ return
+ }
+ event.preventDefault()
+ event.stopPropagation()
+ cleanupResizeRef.current?.()
+
+ const header = event.currentTarget.closest('th')
+ if (header) {
+ onResizeStart?.(header)
+ }
+ const startWidth = header?.getBoundingClientRect().width || MIN_COLUMN_WIDTH
+ const startX = event.clientX
+ let latestX = startX
+ let didResize = false
+ let animationFrame: number | null = null
+
+ const applyResize = (): void => {
+ animationFrame = null
+ onResize(Math.min(MAX_COLUMN_WIDTH, Math.max(MIN_COLUMN_WIDTH, startWidth + latestX - startX)))
+ }
+ const onMouseMove = (moveEvent: MouseEvent): void => {
+ latestX = moveEvent.clientX
+ didResize ||= latestX !== startX
+ if (animationFrame === null) {
+ animationFrame = requestAnimationFrame(applyResize)
+ }
+ }
+ const cleanup = (): void => {
+ window.removeEventListener('mousemove', onMouseMove)
+ window.removeEventListener('mouseup', onMouseUp)
+ document.body.classList.remove('is-resizing-column')
+ cleanupResizeRef.current = null
+ }
+ const onMouseUp = (): void => {
+ if (animationFrame !== null) {
+ cancelAnimationFrame(animationFrame)
+ applyResize()
+ }
+ if (didResize) {
+ onResizeEnd?.()
+ }
+ cleanup()
+ }
+
+ cleanupResizeRef.current = cleanup
+ window.addEventListener('mousemove', onMouseMove)
+ window.addEventListener('mouseup', onMouseUp)
+ document.body.classList.add('is-resizing-column')
+ }
+
+ return (
+ <button
+ type="button"
+ className="absolute top-0 right-0 h-full w-2 translate-x-1/2 cursor-col-resize border-0 bg-transparent p-0 after:absolute after:inset-y-1/4 after:left-1/2 after:w-px after:-translate-x-1/2 after:bg-border hover:bg-primary-highlight focus-visible:bg-primary-highlight focus-visible:outline-none"
+ aria-label="Resize column"
+ onClick={(event) => event.stopPropagation()}
+ onMouseDown={startResize}
+ />
+ )
+}
diff --git a/frontend/src/lib/lemon-ui/LemonTable/types.ts b/frontend/src/lib/lemon-ui/LemonTable/types.ts
index 330afd3cd8c9..483ee23490ef 100644
--- a/frontend/src/lib/lemon-ui/LemonTable/types.ts
+++ b/frontend/src/lib/lemon-ui/LemonTable/types.ts
@@ -54,6 +54,12 @@ export interface LemonTableColumn<T extends Record<string, any>, D extends keyof
sticky?: boolean
/** Set width. */
width?: string | number
+ /** Allow people to resize this column from its header. */
+ resizable?: boolean
+ /** Called while a person resizes this column. */
+ onResize?: (width: number) => void
+ /** Called after a person finishes resizing this column. */
+ onResizeEnd?: () => void
/** Whether the column's contents should expand to the size of the column. */
fullWidth?: boolean
/** Cell actions to display in a "More" menu for each cell. Return null to hide actions for specific cells. */
diff --git a/frontend/src/queries/nodes/DataTable/DataTable.tsx b/frontend/src/queries/nodes/DataTable/DataTable.tsx
index 41fc10df2af3..2b1f89b0de6b 100644
--- a/frontend/src/queries/nodes/DataTable/DataTable.tsx
+++ b/frontend/src/queries/nodes/DataTable/DataTable.tsx
@@ -1062,6 +1062,8 @@ export function DataTable({
className="DataTable"
loading={responseLoading && !nextDataLoading && !newDataLoading}
columns={lemonColumns}
+ tableLayout={context?.tableLayout}
+ tableStyle={context?.tableStyle}
embedded={embedded}
key={
[...(columnsInResponse ?? []), ...columnsInQuery].join(
diff --git a/frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx b/frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx
index 605dabe379ba..b6c4eea0b086 100644
--- a/frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx
+++ b/frontend/src/queries/nodes/DataTable/renderColumnMeta.tsx
@@ -23,6 +23,9 @@ export interface ColumnMeta {
title?: JSX.Element | string
width?: string | number
align?: 'left' | 'right' | 'center'
+ resizable?: boolean
+ onResize?: (width: number) => void
+ onResizeEnd?: () => void
}
export function renderColumnMeta<T extends DataVisualizationNode | DataTableNode>(
@@ -151,6 +154,13 @@ export function renderColumnMeta<T extends DataVisualizationNode | DataTableNode
return {
title,
...(typeof width !== 'undefined' ? { width } : {}),
+ ...(queryContextColumn?.resizable && queryContextColumn.onResize
+ ? {
+ resizable: true,
+ onResize: queryContextColumn.onResize,
+ onResizeEnd: queryContextColumn.onResizeEnd,
+ }
+ : {}),
...(align ? { align } : {}),
}
}
diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.ts
index e495d81ef184..afb8fbc91d72 100644
--- a/frontend/src/queries/types.ts
+++ b/frontend/src/queries/types.ts
@@ -1,4 +1,4 @@
-import { ComponentType, HTMLProps } from 'react'
+import { CSSProperties, ComponentType, HTMLProps } from 'react'
import { ExpandableConfig } from 'lib/lemon-ui/LemonTable'
@@ -20,6 +20,8 @@ import { DataTableRow } from './nodes/DataTable/dataTableLogic'
export interface QueryContext<Q extends QuerySchema = QuerySchema> {
/** Column templates for the DataTable */
columns?: Record<string, QueryContextColumn>
+ tableLayout?: 'auto' | 'fixed'
+ tableStyle?: CSSProperties
/** used to override the value in the query */
showOpenEditorButton?: boolean
showQueryEditor?: boolean
@@ -108,7 +110,10 @@ export interface QueryContextColumn {
renderTitle?: QueryContextColumnTitleComponent
render?: QueryContextColumnComponent
align?: 'left' | 'right' | 'center' // default is left
- width?: string
+ width?: string | number
+ resizable?: boolean
+ onResize?: (width: number) => void
+ onResizeEnd?: () => void
hidden?: boolean // don't show this column in the table
isRowFillFraction?: boolean // if true, this row will be filled with a background color based on the value (from 0 to 1)
}
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index f3ac0b331e08..2f72571b93f5 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -43,7 +43,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc
| Logic | Owns |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountsLogic` | The hub. Search (debounced), tag / assigned-to/unassigned / native-field / relationship / custom-property filters, sort, inline role and editable custom-property assignment, typed Postgres list and metrics queries, shareable URL-hash view state, and `openAccount` (the Max entry point). `accountsTableQueryPlan` translates live, saved-view, and URL-restored state into typed references. `connect`s column-config, overview-tiles, and expansion logics. |
-| `accountsViewsLogic` | Saved-views lifecycle (list/create/update/delete/select). Connects to `accountsLogic`, `accountsColumnConfigLogic`, and `accountsOverviewTilesLogic`; is the single owner of reading and writing the `ColumnConfiguration` rows for this area. |
+| `accountsViewsLogic` | Saved-views lifecycle (list/create/update/delete/select) and browser-persisted column widths. Connects to `accountsLogic`, `accountsColumnConfigLogic`, and `accountsOverviewTilesLogic`; is the single owner of reading and writing the `ColumnConfiguration` rows for this area. |
| `accountsColumnConfigLogic` | Selected columns (`selectColumns` / `visibleColumnNames`), Postgres-backed column-picker groups, the per-team saved column config (`columnConfigurations` API), and custom-property definitions. It seeds `propertyDefinitionsModel` so the filter UI resolves per-type operator sets. Warehouse-backed columns and SQL expressions are not offered. |
| `accountsExpansionLogic` | Which rows are expanded (`expandedAccountIds`) and the active tab per account (`activeTabByAccount`). Pure state — no DOM, no data fetching. |
| `accountsOverviewTilesLogic` | The overview metric tiles (saved in views via `properties.tiles`). It translates supported tile definitions into typed Postgres metrics for `accountsLogic.metricsQuery`, then reads the separate metrics data node. Reads legacy per-team localStorage tiles **read-only** on mount + emits an `OverviewTilesLocalStorageRead` tombstone; never writes localStorage. |
@@ -62,7 +62,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc
## Data & query model
-`accountsLogic.accountsTableQueryPlan` translates selected columns, filters, custom-property display windows, tile filters, and server-side sort into a typed `AccountsTableQuery`. Unsupported saved columns and filters are omitted instead of switching execution engines. `AccountsTable` reads each keyed `AccountsTableRow` directly through `accountsTableCell`; there is no positional-row compatibility transform.
+`accountsLogic.accountsTableQueryPlan` translates selected columns, filters, custom-property display windows, tile filters, and server-side sort into a typed `AccountsTableQuery`. Unsupported saved columns and filters are omitted instead of switching execution engines. `AccountsTable` reads each keyed `AccountsTableRow` directly through `accountsTableCell`; there is no positional-row compatibility transform. Every column can be resized from its header down to 80px. Widths save automatically in one team-scoped local storage dictionary keyed by stable column alias. A column keeps its width when a view hides it, then restores it when another view shows it.
Ignored accounts (`ignored_at IS NOT NULL`) are excluded from list rows and overview metrics by default. A direct account route sets `includeIgnored` as well as `includeChurned`, so an ignored account still opens by id. `ignored_at` is a selectable account field, but the Accounts UI does not write it.
@@ -190,7 +190,7 @@ The Notes tab is server-paginated, searchable, and sortable (all via `accountNot
## Shareable view state
-`accountsLogic` mirrors the full view (search, tags, unassigned, assigned-to, native-field and custom-property filters, sort, columns, tile filter) into the URL hash `#view=...` via `actionToUrl`/`urlToAction`, so a copied URL reproduces the exact list. Only non-default values are serialized. The "assigned to" filter persists as concrete `assignedTo` ids (not a `mine` flag), so a link shared with a colleague resolves to the **same** accounts for them as for the sharer; the legacy `mine: true` hash is still read and resolved to the current user's id for backward compatibility. A shared link's `columns` win over the per-user saved column config (`accountsColumnConfigLogic` enforces this when its async saved-config load resolves by checking the live URL).
+`accountsLogic` mirrors the full view (search, tags, unassigned, assigned-to, native-field and custom-property filters, sort, columns, tile filter) into the URL hash `#view=...` via `actionToUrl`/`urlToAction`, so a copied URL reproduces the exact list. Column widths stay in browser-local preferences instead of the URL because they are display preferences. Only non-default values are serialized. The "assigned to" filter persists as concrete `assignedTo` ids (not a `mine` flag), so a link shared with a colleague resolves to the **same** accounts for them as for the sharer; the legacy `mine: true` hash is still read and resolved to the current user's id for backward compatibility. A shared link's `columns` win over the per-user saved column config (`accountsColumnConfigLogic` enforces this when its async saved-config load resolves by checking the live URL).
### Deep-link to one account (path route)
@@ -309,6 +309,7 @@ We track user actions on the Accounts list with `posthog.capture()`. Conventions
| `customer analytics accounts searched` | `accountsLogic` `setSearchInput` listener (post-debounce) | `query_length`, `has_query`, `active_filter_count` |
| `customer analytics accounts refreshed` | `accountsLogic` `refresh` | `has_search`, `active_filter_count`, `sort_column` |
| `customer analytics accounts sorted` | `accountsLogic` `toggleSort` | `column`, `direction` (`asc` \| `desc` \| `cleared`) |
+| `customer analytics accounts column resized` | `accountsViewsLogic` `reportColumnResize` after a header drag | _(none — column names can contain customer property names)_ |
| `customer analytics accounts account opened` | `AccountsTableNameCell.tsx` account-name `<Link>` `onClick` (only when the row expands in the legacy experience) | _(none — the row's `id` is customer PII-adjacent and kept out)_ |
| ~~`customer analytics accounts columns saved`~~ | _Deprecated — no longer emitted. Column changes are now saved as part of a view (see view events below)._ | _n/a_ |
| `customer analytics accounts overview tiles edited` | `accountsOverviewTilesLogic` editor close (diffed vs open snapshot, only when changed) | `tiles_added`, `tiles_removed`, `tiles_updated`, `reordered`, `tile_count_before`, `tile_count_after` |
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
index b748ff919032..cdfeb1258b13 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
@@ -49,6 +49,7 @@ import { AccountExpansionTab, accountsExpansionLogic } from './accountsExpansion
import { accountsLogic, customPropertySavingKey, savingRoleKey } from './accountsLogic'
import { AccountsTableNameCell } from './AccountsTableNameCell'
import { accountsTableCell, isAccountsTableRow } from './accountsTableQuery'
+import { accountsViewsLogic } from './accountsViewsLogic'
// Shape the name renderer uses from the keyed AccountsTableRow identity fields.
type AccountNameCellData = { name: string; external_id: string | null; id: string; logo_domain: string | null }
@@ -719,14 +720,23 @@ const KNOWN_COLUMN_TEMPLATES: Record<string, KnownColumnTemplate> = {
function useContextColumns(): Record<string, QueryContextColumn> {
const { visibleColumnNames, aliasToDefinition, aliasToRelationshipDefinition, displayByAlias } =
useValues(accountsColumnConfigLogic)
+ const { columnWidths } = useValues(accountsViewsLogic)
+ const { setColumnWidth, reportColumnResize } = useActions(accountsViewsLogic)
return useMemo(() => {
const columns: Record<string, QueryContextColumn> = {}
for (const key of visibleColumnNames) {
+ const resizeHandlers = {
+ resizable: true,
+ onResize: (width: number) => setColumnWidth(key, width),
+ onResizeEnd: reportColumnResize,
+ }
const definition = aliasToDefinition[key]
if (definition) {
const display = displayByAlias[key]
columns[key] = {
renderTitle: () => <SortableColumnHeader column={key} label={definition.name} />,
+ width: columnWidths[key],
+ ...resizeHandlers,
render: ({ record }) => (
<CustomPropertyCell
record={record}
@@ -743,7 +753,8 @@ function useContextColumns(): Record<string, QueryContextColumn> {
if (relationshipDefinition) {
columns[key] = {
renderTitle: () => <SortableColumnHeader column={key} label={relationshipDefinition.name} />,
- width: COLUMN_WIDTHS.relationship,
+ width: columnWidths[key] ?? COLUMN_WIDTHS.relationship,
+ ...resizeHandlers,
render: ({ record }) => (
<RelationshipCell record={record} column={key} definition={relationshipDefinition} />
),
@@ -754,12 +765,21 @@ function useContextColumns(): Record<string, QueryContextColumn> {
const label = template?.label ?? key
columns[key] = {
renderTitle: () => <SortableColumnHeader column={key} label={label} />,
- width: template?.width,
+ width: columnWidths[key] ?? template?.width,
+ ...resizeHandlers,
render: template?.render ?? (({ record }) => <DefaultAccountCell record={record} column={key} />),
}
}
return columns
- }, [visibleColumnNames, aliasToDefinition, aliasToRelationshipDefinition, displayByAlias])
+ }, [
+ visibleColumnNames,
+ aliasToDefinition,
+ aliasToRelationshipDefinition,
+ displayByAlias,
+ columnWidths,
+ setColumnWidth,
+ reportColumnResize,
+ ])
}
function useExpandable(): QueryContext<DataTableNode>['expandable'] {
@@ -862,6 +882,7 @@ function AccountsTableSkeleton({ expandable }: { expandable: boolean }): JSX.Ele
export function AccountsTable(): JSX.Element {
const { accountsDataTableQuery, accountsQuerySource, sortedRowsTransformer } = useValues(accountsLogic)
+ const { columnWidths } = useValues(accountsViewsLogic)
const { responseLoading, response } = useValues(
dataNodeLogic({
key: ACCOUNTS_TABLE_DATA_NODE_KEY,
@@ -887,6 +908,8 @@ export function AccountsTable(): JSX.Element {
}}
context={{
columns: contextColumns,
+ tableLayout: 'fixed',
+ tableStyle: Object.keys(columnWidths).length > 0 ? { width: 'max-content' } : undefined,
expandable,
dataTableRowsTransformer: sortedRowsTransformer,
dataNodeLogicKey: ACCOUNTS_TABLE_DATA_NODE_KEY,
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
index 0d4e1bf52d3d..05e6339f58e1 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
@@ -137,6 +137,16 @@ describe('accountsViewsLogic', () => {
])
})
+ it('keeps column widths when the selected view changes', async () => {
+ useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 0, results: [] } } })
+ mountAll()
+
+ logic.actions.setColumnWidth('name', 320)
+ logic.actions.setCurrentViewId('view-1')
+
+ await expectLogic(logic).toMatchValues({ columnWidths: { name: 320 } })
+ })
+
it('isDirty flips when live state diverges from the applied view and clears on re-apply', async () => {
useMocks({
get: {
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
index 5b3282f150e0..d55650070bbe 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
@@ -31,6 +31,7 @@ import {
import { AccountsEvents, DEFAULT_TILES } from './constants'
export type ViewVisibility = 'private' | 'shared'
+export type AccountColumnWidthState = Record<string, number>
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface accountsViewsLogicValues {
@@ -47,6 +48,7 @@ export interface accountsViewsLogicValues {
currentTeamId: number | null // teamLogic
user: UserType | null // userLogic
canEditCurrentView: boolean
+ columnWidths: AccountColumnWidthState
currentView: ColumnConfigurationApi | null
currentViewId: string | null
isCreating: boolean
@@ -204,6 +206,9 @@ export interface accountsViewsLogicActions {
properties: AccountsViewProperties
}
}
+ reportColumnResize: () => {
+ value: true
+ }
resetNewViewForm: (values?: { name: string; visibility: ViewVisibility }) => {
values?: {
name: string
@@ -218,6 +223,13 @@ export interface accountsViewsLogicActions {
selectView: (id: string) => {
id: string
}
+ setColumnWidth: (
+ column: string,
+ width: number
+ ) => {
+ column: string
+ width: number
+ }
setCurrentViewId: (id: string | null) => {
id: string | null
}
@@ -407,6 +419,8 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
selectView: (id: string) => ({ id }),
applyView: (view: ColumnConfigurationApi) => ({ view }),
setCurrentViewId: (id: string | null) => ({ id }),
+ setColumnWidth: (column: string, width: number) => ({ column, width }),
+ reportColumnResize: true,
setIsCreating: (isCreating: boolean) => ({ isCreating }),
setViewToDelete: (id: string | null) => ({ id }),
setViewToRename: (id: string | null) => ({ id }),
@@ -460,6 +474,16 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
deleteViewSuccess: (state, { views }) => (state && !views.find((v) => v.id === state) ? null : state),
},
],
+ columnWidths: [
+ {} as AccountColumnWidthState,
+ {
+ persist: true,
+ storageKey: `customerAnalytics.accounts.accountsViewsLogic.${getCurrentTeamId()}.columnWidths`,
+ },
+ {
+ setColumnWidth: (state, { column, width }) => ({ ...state, [column]: width }),
+ },
+ ],
isCreating: [
false,
{
@@ -572,6 +596,9 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
},
})),
listeners(({ actions, values }) => ({
+ reportColumnResize: () => {
+ posthog.capture(AccountsEvents.ColumnResized)
+ },
selectView: ({ id }) => {
const view = values.views.find((v) => v.id === id)
if (view) {
diff --git a/products/customer_analytics/frontend/components/Accounts/constants.ts b/products/customer_analytics/frontend/components/Accounts/constants.ts
index be5517a05350..5989a1c42e59 100644
--- a/products/customer_analytics/frontend/components/Accounts/constants.ts
+++ b/products/customer_analytics/frontend/components/Accounts/constants.ts
@@ -32,6 +32,7 @@ export const AccountsEvents = {
Searched: 'customer analytics accounts searched',
Refreshed: 'customer analytics accounts refreshed',
Sorted: 'customer analytics accounts sorted',
+ ColumnResized: 'customer analytics accounts column resized',
AccountOpened: 'customer analytics accounts account opened',
ColumnsSaved: 'customer analytics accounts columns saved',
OverviewTilesEdited: 'customer analytics accounts overview tiles edited',