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(customer-analytics): constrain account tag editor to column (#108240)

Paul D'Ambrabbad9e7e3cd2
diff --git a/docs/internal/customer-analytics/accounts-table.md b/docs/internal/customer-analytics/accounts-table.md
index ac924cc9e720..58cc17f1f42b 100644
--- a/docs/internal/customer-analytics/accounts-table.md
+++ b/docs/internal/customer-analytics/accounts-table.md
@@ -77,6 +77,8 @@ Measurements run after render, reuse widths while the sampled markup is unchange
Automatic widths stay local to the mounted table and are not saved to browser storage.
Users can still drag column header boundaries to resize columns, including beyond 200px.
+The tag editor fits the current tag column width, even after a resize.
+Long tags truncate inside the editor instead of spilling into the next cell.
`accountsViewsLogic` stores manual widths per team and column in browser local storage, independently of saved views.
Hiding a column does not discard its saved width.
Automatic sizing uses the existing resized-table layout and does not change scroll controls.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index f45e65e70c4a..50985af1dbfd 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5424,6 +5424,10 @@ snapshots:
hash: v1.k794b7964.62481a20890d8d9702570d58b69f47580c91399daa635cab23d9e8da75d2636f.4zz_BsbTTGbjpB2UW_cLkBiMwGDI54MGoQlD9_b9hV8
lemon-ui-object-tags--default--light:
hash: v1.k794b7964.1a69b09d2bc7612599daf0a1228b103250debc4afa2224fb8005e3c9b7f63326.bYCI4pCGFv3tFdGcQfIkfzDcOnpuLhD10S33l9BYIYg
+ lemon-ui-object-tags--editable-tags-in-narrow-container--dark:
+ hash: v1.k794b7964.6538590671c5bcd8feb77e0400c8532705932f4f55856dd6a99a6abcdc00b6e3.ca3qOKbmxmRDrNfdNRCEg9I9Wvnkrs7PHzA0tvpXTIM
+ lemon-ui-object-tags--editable-tags-in-narrow-container--light:
+ hash: v1.k794b7964.8b8f244a4387d0d1165067851b5758f5ad5429fae2b4a4e87eb7c53cdfdd4e18.MekQJYDe11n-5XnhJV5phxqMh5OqTw36CTFCk_BZNnw
lemon-ui-object-tags--static-only--dark:
hash: v1.k794b7964.62481a20890d8d9702570d58b69f47580c91399daa635cab23d9e8da75d2636f.oAaWHdceTRTQOchqDXvZ7-ym0DB_CpRpPyXnqlKugwo
lemon-ui-object-tags--static-only--light:
diff --git a/frontend/src/lib/components/ObjectTags/ObjectTags.stories.tsx b/frontend/src/lib/components/ObjectTags/ObjectTags.stories.tsx
index e330239a937e..c938c0ddd339 100644
--- a/frontend/src/lib/components/ObjectTags/ObjectTags.stories.tsx
+++ b/frontend/src/lib/components/ObjectTags/ObjectTags.stories.tsx
@@ -1,4 +1,6 @@
import type { Meta, StoryObj } from '@storybook/react'
+import { waitFor, within } from '@testing-library/dom'
+import userEvent from '@testing-library/user-event'
import { ObjectTags, ObjectTagsProps } from './ObjectTags'
@@ -28,3 +30,35 @@ export const WrapLongTagsInNarrowContainer: Story = {
</div>
),
}
+
+export const EditableTagsInNarrowContainer: Story = {
+ render: () => (
+ <div className="w-40 rounded border p-2" data-attr="narrow-tags-container">
+ <ObjectTags
+ tags={['first tag', 'a long tag that exceeds the available width', 'third tag']}
+ onChange={() => {}}
+ saving={false}
+ editorFullWidth
+ />
+ </div>
+ ),
+ play: async ({ canvasElement }: { canvasElement: HTMLElement }): Promise<void> => {
+ const container = canvasElement.querySelector<HTMLElement>('[data-attr="narrow-tags-container"]')
+ if (!container) {
+ throw new Error('Expected a narrow tags container')
+ }
+ await userEvent.click(within(container).getByText('Edit tags'))
+ await waitFor(() => {
+ const editor = container.querySelector<HTMLElement>('[data-attr="new-tag-input"]')
+ const editorBounds = editor?.getBoundingClientRect()
+ const containerBounds = container.getBoundingClientRect()
+ if (
+ !editorBounds ||
+ editorBounds.left < containerBounds.left ||
+ editorBounds.right > containerBounds.right
+ ) {
+ throw new Error('The tag editor must fit inside its container')
+ }
+ })
+ },
+}
diff --git a/frontend/src/lib/components/ObjectTags/ObjectTags.tsx b/frontend/src/lib/components/ObjectTags/ObjectTags.tsx
index 7fec76498884..4eb9f86cd809 100644
--- a/frontend/src/lib/components/ObjectTags/ObjectTags.tsx
+++ b/frontend/src/lib/components/ObjectTags/ObjectTags.tsx
@@ -36,6 +36,7 @@ interface ObjectTagsPropsBase {
* room surrounding table columns get.
*/
wrap?: boolean
+ editorFullWidth?: boolean
}
export type ObjectTagsProps =
@@ -81,6 +82,7 @@ export function ObjectTags({
maxVisibleTags,
showOverflowLabel = false,
wrap = false,
+ editorFullWidth = false,
}: ObjectTagsProps): JSX.Element {
const objectTagId = useId()
const logic = objectTagsLogic({ id: objectTagId, onChange })
@@ -103,7 +105,12 @@ export function ObjectTags({
<div
// eslint-disable-next-line react/forbid-dom-props
style={style}
- className={clsx(className, 'inline-flex flex-wrap gap-0.5 items-center', wrap && 'min-w-0 max-w-full')}
+ className={clsx(
+ className,
+ 'inline-flex flex-wrap gap-0.5 items-center',
+ wrap && 'min-w-0 max-w-full',
+ editingTags && editorFullWidth && 'w-full min-w-0'
+ )}
data-attr={dataAttr}
>
{editingTags ? (
@@ -121,6 +128,7 @@ export function ObjectTags({
data-attr="new-tag-input"
placeholder={inputPlaceholder}
autoFocus
+ fullWidth={editorFullWidth}
popoverClassName="click-outside-block"
/>
) : (
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index c1b6d0964ff3..d600262b86ee 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -103,6 +103,8 @@ The server selects the first valid hostname from:
The `tag_names` cell is editable in place: `TagsCell` renders the editable `ObjectTags` variant and loads available tags from `tagsModel` when editing starts. The All tags filter and account detail sidebar use the same lazy-load behavior. Tag edits save through the account PATCH via `accountsLogic.updateAccountTags` — optimistic per-account override (`tagOverrides`, masking the stale fetched cell like `relationshipOverrides`), debounced full-list PATCH (`TAGS_SAVE_DEBOUNCE_MS`, since `ObjectTags` fires per added/removed tag), `savingTags` guard, revert + toast + captured exception on failure. Clicking a tag in the cell adds it to the tags filter, compounding with tags already filtered (`addTagToFilter` — dedupes, and reports through `reportFilterChange('tag')` like the filter control).
+The Accounts table sets `editorFullWidth` so the tag editor fits its column after a manual resize. The `EditableTagsInNarrowContainer` ObjectTags story checks the narrow editor layout.
+
Default columns: `name`, `tag_names`, `notebook_count`, plus one relationship column per team definition. `ACCOUNTS_DEFAULT_COLUMNS` is the stored-state seed name, but execution is fully typed. Once `loadRelationshipDefinitionsSuccess` fires, still-default columns upgrade to `defaultSelectColumns`. The name column is force-kept because removing it breaks identity, scroll, and role edits. `buildAccountColumnGroups` offers tags as one `tags` option with the `tags` type under Account properties instead of exposing the raw tags join fields. Restoring a saved view maps the old raw `names` expression to this column and removes the unsupported raw `account_id` expression. It also offers typed account fields, notes, relationships, and custom properties. Warehouse-backed columns, arbitrary lazy joins, and SQL expressions are unsupported. Older saved expressions are omitted from the query plan.
**Custom property columns** surface the team's `CustomPropertyDefinition`s (loaded in `accountsColumnConfigLogic` via the generated `customPropertyDefinitionsList`) as a "Custom properties" picker group. Each is selected as ``accounts.custom_properties.values.`<definition-id>` AS cp_<id>`` — a JSON dot-access through the `custom_properties` lazy join on `system.accounts` (backed by the `customer_analytics_custompropertyvalue` EAV table; one JOIN regardless of column count). Because the alias is an opaque `cp_<id>`, every label-bearing surface must resolve it back via the `aliasToDefinition` selector: the table header (`useContextColumns` in `AccountsTable`) and the configurator's "Visible columns" list (`SelectedAccountColumn`). Cells render by display type (`CustomPropertyCell`: date→`TZLabel`, boolean→icon, link→new-tab URL, select→`LemonColorGlyph` + label, numeric→`formatCustomPropertyValue`). Server-side sorting uses the typed custom property reference, and the backend chooses the value column from the definition's display type. The stored sort state (URL hash, saved views) keeps the clean column name. Numeric custom properties are also selectable in the **overview tiles** sum/avg/min/max/median/threshold pickers — `numericColumnOptions` recognizes the display type and wraps the value in `toFloatOrNull(...)` the same way so aggregation is numeric.
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
index 951a64054297..5da98ff21b61 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTab.stories.tsx
@@ -739,7 +739,7 @@ export const RowExpandedPinnedPropertiesError: Story = {
render: () => <App />,
parameters: {
...PINNED_ROW_PARAMETERS,
- testOptions: { waitForSelector: `${PINNED_EXPANSION_SELECTOR} button` },
+ testOptions: { waitForSelector: `${PINNED_EXPANSION_SELECTOR} .LemonBanner--error` },
},
decorators: pinnedRowDecorators({
[ACCOUNT_PROPERTY_VALUES_ENDPOINT]: [500, { detail: 'Could not load pinned properties.' }],
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
index 70bf476da671..893e83521d99 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
@@ -128,6 +128,7 @@ function TagsCell({ record }: { record: unknown }): JSX.Element {
saving={isTagsSaving(accountId) || tagsLoading}
tagsAvailable={(tagsAvailable || []).filter((tag) => !tags.includes(tag))}
data-attr="accounts-tags-cell"
+ editorFullWidth
/>
)
}