From c52f6706ae257b7816c2a38ae10f0e0d0e316e0e Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 13:27:46 +0000 Subject: [PATCH 1/8] test(e2e): geometry harness for the narrowed app list's fixed columns Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY Co-authored-by: Claude --- .../list-narrow-pinned-columns-35446.spec.ts | 434 ++++++++++++++++++ 1 file changed, 434 insertions(+) create mode 100644 ui/e2e/list-narrow-pinned-columns-35446.spec.ts diff --git a/ui/e2e/list-narrow-pinned-columns-35446.spec.ts b/ui/e2e/list-narrow-pinned-columns-35446.spec.ts new file mode 100644 index 00000000000..0306e716503 --- /dev/null +++ b/ui/e2e/list-narrow-pinned-columns-35446.spec.ts @@ -0,0 +1,434 @@ +import { test, expect, type Page } from '@playwright/test'; +import { compile } from 'tailwindcss'; +import { build, type Plugin, type Rollup } from 'vite'; +import { readFileSync } from 'node:fs'; +import { createRequire } from 'node:module'; +import os from 'node:os'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; +import { uiRoot } from '../scripts/ui-root.mjs'; + +/** + * GEOMETRY pin for objectstack#35446: an app list whose main area narrows (the + * AI panel docked, a small window, the record drawer open) keeps every data + * cell clear of the grid's fixed columns, keeps its name column frozen, and + * shows its horizontal scrollbar while columns lie out of view. + * + * ## The defect + * + * The grid pinned its row-actions column (the row's "⋮") to the scroll box's + * right edge. In a narrow box the table overflows, so at rest the pinned + * column sat over whichever data column reached that edge (the card measured + * the amount column cut to 「¥94,0」), and the scrollbar was transparent until + * the pointer was over the box, so nothing said more columns lay to the right. + * Now, while the table overflows its box, the "⋮" column joins the frozen zone + * beside the name column (`useInlineRowActionFold` in plugin-grid) and the + * scroll box draws its scrollbar at rest (`data-table`). + * + * ## Why a Playwright spec and not a vitest test + * + * jsdom and happy-dom have no layout engine: no widths, no sticky offsets, no + * `elementFromPoint`, and the move is decided from the widths the table draws. + * The bundling follows `e2e/related-list-pinned-actions-width.spec.ts`. + * + * ## What is real here and what is a fixture + * + * REAL: plugin-grid's `ObjectGrid`, the `data-table` and `RowActionMenu`, + * bundled by Vite from their source files and mounted in Chromium with React's + * client renderer; the stylesheet is real Tailwind + * (`packages/components/src/index.css`, its `@theme` included), compiled for + * exactly the classes the mounted page carries. The row menu is opened and its + * action dispatched with real pointer clicks. + * + * FIXTURES, declared so nobody reads more into a green run than it says: + * + * - The rows, the object's fields and the row actions are literals shaped + * like the card's opportunity list; the data source answers them and the + * dispatched action is recorded on the page, not run. + * - The width is set by a frame around the grid, not by the AI panel, a + * window or a drawer: the rule reads the grid's own box, so the cause of + * the narrowing is not an input. 699 px is the main area the card measured + * with the AI panel docked in a 1167 px window; 1184 px is the list page's + * table width at a 1440 px window with the sidebar open (the reading + * `related-list-pinned-actions-width.spec.ts` names). + * - Fonts are Chromium's fallbacks. The assertions are overlaps, hits and + * which edge a column sticks to, not pixels; the readings go to the report. + */ + +const REPO_ROOT = uiRoot(); +const source = (rel: string) => path.join(REPO_ROOT, rel); + +const THEME_CSS = source('packages/components/src/index.css'); +// The entry names workspace sources by path, never by package name: the e2e +// type-check program must import no workspace package (it builds nothing first). +const PLUGIN_GRID = source('packages/plugin-grid/src/index.tsx'); +const FIELDS = source('packages/fields/src/index.tsx'); +const REACT_BINDINGS = source('packages/react/src/index.ts'); + +/** The main area with the AI panel docked in a 1167 px window (the card's case). */ +const AI_PANEL_MAIN = 699; +/** The list page's table width at a 1440 px window (see the header). */ +const FULL_PAGE = 1184; + +/** The card's opportunity list, name first and the close date last. */ +const COLUMNS = ['name', 'account', 'stage', 'amount', 'probability', 'expected_revenue', 'close_date']; +/** Few enough to fit the narrow frame: nothing overflows, nothing moves. */ +const FEW_COLUMNS = ['name', 'stage', 'amount']; + +interface Case { + name: string; + viewport: number; + frame: number; + columns: string[]; + /** Give each row one inline primary action beside the "⋮". */ + inlinePrimary?: boolean; +} + +const ENTRY = '\0list-narrow-pinned-columns:entry'; + +/** `@object-ui/` to `packages//src`, and a subpath into that `src/`. */ +function workspaceSources(): Plugin { + return { + name: 'list-narrow-pinned-columns-workspace-src', + enforce: 'pre', + async resolveId(id, importer) { + const m = /^@object-ui\/([a-z0-9-]+)(?:\/(.+))?$/.exec(id); + if (!m) return null; + const [, pkg, sub] = m; + const target = + pkg === 'types' && sub === 'zod' + ? source('packages/types/src/zod/index.zod.ts') + : source(`packages/${pkg}/src${sub ? `/${sub}` : ''}`); + const resolved = await this.resolve(target, importer, { skipSelf: true }); + if (!resolved) throw new Error(`${id} did not resolve to a source file under ${target}`); + return resolved; + }, + }; +} + +/** The page: the case named by `window.__case`, mounted with the client renderer. */ +function entry(): Plugin { + const code = ` +import * as React from 'react'; +import { createRoot } from 'react-dom/client'; +import { ObjectGrid } from ${JSON.stringify(PLUGIN_GRID)}; +import { registerAllFields } from ${JSON.stringify(FIELDS)}; +import { ActionProvider, SchemaRendererProvider } from ${JSON.stringify(REACT_BINDINGS)}; + +registerAllFields(); +const h = React.createElement; +const c = window.__case; +window.__dispatched = []; +const FIELDS = { + id: { name: 'id', type: 'text' }, + name: { name: 'name', label: 'Opportunity name', type: 'text' }, + account: { name: 'account', label: 'Account', type: 'text' }, + stage: { name: 'stage', label: 'Stage', type: 'text' }, + amount: { name: 'amount', label: 'Amount', type: 'currency' }, + probability: { name: 'probability', label: 'Probability', type: 'percent' }, + expected_revenue: { name: 'expected_revenue', label: 'Expected revenue', type: 'currency' }, + close_date: { name: 'close_date', label: 'Expected close date', type: 'date' }, +}; +const ROWS = [ + ['Vertex Enterprise Rollout', 'Vertex Analytics', 'Negotiation', 94000, 80], + ['Wayne Enterprise License', 'Wayne Enterprises', 'Negotiation', 1200000, 80], + ['Lattice Education Renewal', 'Lattice Education', 'Proposal', 87000, 60], +].map(([name, account, stage, amount, probability], i) => ({ + id: 'o' + (i + 1), name, account, stage, amount, probability, + expected_revenue: amount * probability / 100, close_date: '2026-12-0' + (i + 1), +})); +const dataSource = { + find: async () => ({ data: ROWS, total: ROWS.length }), + getObjectSchema: async (name) => ({ name, fields: FIELDS }), +}; +const rowActionDefs = [ + ...(c.inlinePrimary ? [{ name: 'advance', label: 'Advance', variant: 'primary' }] : []), + { name: 'archive', label: 'Archive' }, +]; +createRoot(document.getElementById('root')).render( + h(ActionProvider, { handlers: Object.fromEntries(rowActionDefs.map((d) => [d.name, async () => { window.__dispatched.push(d.name); return { success: true }; }])) }, + h(SchemaRendererProvider, { dataSource }, + h('div', { id: 'frame', className: 'flex flex-col bg-background', style: { width: c.frame + 'px', height: '520px' } }, + h(ObjectGrid, { + dataSource, + schema: { + type: 'object-grid', + objectName: 'opportunity', + columns: c.columns.map((field) => ({ field, label: FIELDS[field].label })), + rowActionDefs, + }, + })))), +); +`; + return { + name: 'list-narrow-pinned-columns-entry', + resolveId: (id) => (id === 'list-narrow-pinned-columns:entry' ? ENTRY : null), + load: (id) => (id === ENTRY ? code : null), + }; +} + +/** Bundle the page once, from source, to one ES module held in memory. */ +async function bundlePage(): Promise { + const result = await build({ + configFile: false, + root: REPO_ROOT, + // Out of the tree: this run must leave nothing behind in the checkout. + cacheDir: path.join(os.tmpdir(), 'objectui-list-narrow-pinned-columns'), + logLevel: 'error', + mode: 'production', + define: { 'process.env.NODE_ENV': JSON.stringify('production') }, + plugins: [workspaceSources(), entry()], + build: { + write: false, + minify: false, + target: 'es2022', + modulePreload: false, + reportCompressedSize: false, + rollupOptions: { + input: 'list-narrow-pinned-columns:entry', + output: { format: 'es', codeSplitting: false }, + }, + }, + }); + const outputs = (Array.isArray(result) ? result : [result]) as Rollup.RollupOutput[]; + const chunks = outputs.flatMap((o) => o.output).filter((o): o is Rollup.OutputChunk => o.type === 'chunk'); + if (chunks.length !== 1) throw new Error(`expected one bundled chunk, got ${chunks.length}`); + return chunks[0].code; +} + +/** The real theme sheet, compiled for the given class candidates. */ +async function tailwindFor(candidates: string[]): Promise { + const requireFromComponents = createRequire(source('packages/components/package.json')); + const twEntry = requireFromComponents.resolve('tailwindcss/index.css'); + const compiler = await compile(readFileSync(THEME_CSS, 'utf8'), { + base: path.dirname(THEME_CSS), + loadStylesheet: async (id: string, base: string) => { + const file = id === 'tailwindcss' ? twEntry : path.resolve(base, id); + return { path: file, base: path.dirname(file), content: readFileSync(file, 'utf8') }; + }, + loadModule: async (id: string) => { + const file = requireFromComponents.resolve(id); + const mod = await import(pathToFileURL(file).href); + return { path: file, base: path.dirname(file), module: mod.default ?? mod }; + }, + }); + return compiler.build(candidates); +} + +let bundle = ''; + +/** Compile the stylesheet until the page's class set stops growing. */ +async function styleUntilStable(page: Page, compiled: Set): Promise { + const classesOnPage = () => + page.evaluate(() => [ + ...new Set( + [...document.querySelectorAll('[class]')].flatMap((el) => (el.getAttribute('class') ?? '').split(/\s+/)).filter(Boolean), + ), + ]); + for (let round = 0; ; round++) { + const candidates = await classesOnPage(); + if (round > 0 && candidates.every((cls) => compiled.has(cls))) break; + if (round === 5) throw new Error('the page kept adding classes; the stylesheet never caught up'); + candidates.forEach((cls) => compiled.add(cls)); + const css = await tailwindFor([...compiled]); + await page.evaluate((text) => { + let sheet = document.getElementById('tailwind'); + if (!sheet) { + sheet = document.createElement('style'); + sheet.id = 'tailwind'; + document.head.appendChild(sheet); + } + sheet.textContent = text; + }, css); + await page.evaluate(() => new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)))); + } +} + +/** Mount the case, style it, and wait until the table's geometry holds still. */ +async function mount(page: Page, c: Case): Promise { + await page.setViewportSize({ width: c.viewport, height: 900 }); + await page.setContent('
'); + await page.evaluate((value) => { + (window as unknown as { __case: Case }).__case = value; + }, c); + await page.addScriptTag({ content: bundle, type: 'module' }); + await page.locator('th[data-column-key="_actions"]').first().waitFor({ state: 'attached', timeout: 30_000 }); + const compiled = new Set(); + await styleUntilStable(page, compiled); + await page.evaluate(() => document.fonts?.ready); + // The table sizes its columns over several passes and the fold and the move + // are read once its size holds: wait for a geometry that holds across 500 ms. + let last = ''; + for (let i = 0; i < 20; i++) { + const now = await page.evaluate(() => { + const box = document.querySelector('[data-table-scroll-box]'); + const host = document.querySelector('[data-row-actions-inline]'); + const state = `${host?.getAttribute('data-row-actions-inline') ?? ''}:${host?.getAttribute('data-row-actions-column') ?? ''}`; + return box ? `${box.clientWidth}:${box.scrollWidth}:${state}` : `none:${state}`; + }); + if (now === last) break; + last = now; + await page.waitForTimeout(500); + } + await styleUntilStable(page, compiled); +} + +interface Reading { + box: { clientWidth: number; scrollWidth: number; scrollbarHeight: number; scrollbarColor: string }; + /** The edge the "⋮" column sticks to, and its box inside the scroll box. */ + actions: { stick: 'left' | 'right' | 'none'; left: number; width: number }; + inlineButtons: number; + /** The header keys in drawn order. */ + order: string[]; + /** The frozen (left-sticky) header keys. */ + frozen: string[]; + /** + * The largest overlap, in px, of a fixed cell's box with a data cell's box + * in the same row (header row and first body row), and the pair. + */ + overlap: { px: number; fixed: string | null; data: string | null }; + /** Data cells of the first body row whose centre lies in view but answers something else. */ + covered: string[]; +} + +/** The table at rest: nothing scrolled. */ +async function readAtRest(page: Page): Promise { + return page.evaluate(() => { + const box = document.querySelector('[data-table-scroll-box]')!; + box.scrollLeft = 0; + const boxRect = box.getBoundingClientRect(); + const view = { left: boxRect.left + box.clientLeft, right: boxRect.left + box.clientLeft + box.clientWidth }; + const headRow = box.querySelector('thead tr')!; + const bodyRow = box.querySelector('tbody tr')!; + const keyAt = (i: number) => (headRow.children[i] as HTMLElement).getAttribute('data-column-key') ?? `#${i}`; + const sticky = (el: Element) => getComputedStyle(el).position === 'sticky'; + let worst = { px: 0, fixed: null as string | null, data: null as string | null }; + for (const row of [headRow, bodyRow]) { + const cells = [...row.children] as HTMLElement[]; + cells.forEach((fixed, i) => { + if (!sticky(fixed)) return; + const f = fixed.getBoundingClientRect(); + cells.forEach((data, j) => { + if (sticky(data) || !headRow.children[j]?.getAttribute('data-column-key')) return; + const d = data.getBoundingClientRect(); + const px = Math.max(0, Math.min(f.right, d.right) - Math.max(f.left, d.left)); + if (px > worst.px) worst = { px: Math.round(px * 10) / 10, fixed: keyAt(i), data: keyAt(j) }; + }); + }); + } + const covered: string[] = []; + ([...bodyRow.children] as HTMLElement[]).forEach((cell, j) => { + const key = headRow.children[j]?.getAttribute('data-column-key'); + if (!key || key === '_actions' || sticky(cell)) return; + const r = cell.getBoundingClientRect(); + const x = r.left + r.width / 2; + if (x <= view.left || x >= view.right) return; + const at = document.elementFromPoint(x, r.top + r.height / 2); + if (!at || !(at === cell || cell.contains(at))) covered.push(key); + }); + const actionsHead = box.querySelector('th[data-column-key="_actions"]')!; + const ar = actionsHead.getBoundingClientRect(); + const cs = getComputedStyle(actionsHead); + const stick = cs.position !== 'sticky' ? 'none' : cs.right === '0px' && cs.left === 'auto' ? 'right' : 'left'; + const heads = [...headRow.children] as HTMLElement[]; + return { + box: { + clientWidth: box.clientWidth, + scrollWidth: box.scrollWidth, + scrollbarHeight: box.offsetHeight - box.clientHeight - box.clientTop * 2, + scrollbarColor: getComputedStyle(box).scrollbarColor, + }, + actions: { stick, left: Math.round(ar.left - boxRect.left), width: Math.round(ar.width) }, + inlineButtons: box.querySelectorAll('[data-testid^="row-action-inline-"]').length, + order: heads.map((h) => h.getAttribute('data-column-key')).filter((k): k is string => !!k), + frozen: heads + .filter((h) => h.getAttribute('data-column-key') && sticky(h) && getComputedStyle(h).left !== 'auto') + .map((h) => h.getAttribute('data-column-key')!), + overlap: worst, + covered, + }; + }); +} + +/** Scrolled to the far right: does the last column's header answer at its centre? */ +async function lastColumnReachable(page: Page, key: string): Promise { + return page.evaluate(async (k) => { + const box = document.querySelector('[data-table-scroll-box]')!; + box.scrollLeft = box.scrollWidth; + await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))); + const head = box.querySelector(`th[data-column-key="${k}"]`)!; + const r = head.getBoundingClientRect(); + const at = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2); + const hit = !!at && (at === head || head.contains(at)); + box.scrollLeft = 0; + return hit; + }, key); +} + +function report(testInfo: import('@playwright/test').TestInfo, c: Case, r: Reading): void { + testInfo.annotations.push({ type: `list-narrow-pinned-columns@${c.name}`, description: JSON.stringify(r) }); + process.stdout.write(`[list-narrow-pinned-columns ${c.name}] ${JSON.stringify(r)}\n`); +} + +/** Open the first row's "⋮" menu with the pointer and run Archive from it. */ +async function archiveFromMenu(page: Page): Promise { + await page.getByTestId('row-action-trigger').first().click(); + await page.getByRole('menuitem', { name: 'Archive' }).click(); + await expect + .poll(() => page.evaluate(() => (window as unknown as { __dispatched: unknown[] }).__dispatched.length)) + .toBe(1); +} + +test.describe('app list in a narrowed main area — no fixed column covers a data cell (objectstack#35446)', () => { + test.beforeAll(async () => { + test.setTimeout(240_000); + bundle = await bundlePage(); + }); + + for (const inlinePrimary of [false, true]) { + test(`AI panel docked (${AI_PANEL_MAIN} px main area${inlinePrimary ? ', inline primary action' : ''}): the "⋮" joins the frozen zone and the rest scrolls`, async ({ page }, testInfo) => { + test.setTimeout(120_000); + const c: Case = { name: `aiPanel${inlinePrimary ? 'Inline' : ''}`, viewport: 1167, frame: AI_PANEL_MAIN, columns: COLUMNS, inlinePrimary }; + await mount(page, c); + const r = await readAtRest(page); + report(testInfo, c, r); + expect(r.box.scrollWidth, 'the fixture no longer overflows the narrow frame').toBeGreaterThan(r.box.clientWidth + 1); + expect(r.overlap.px, `the fixed column ${r.overlap.fixed} covers ${r.overlap.data} by ${r.overlap.px} px at rest`).toBeLessThanOrEqual(0.5); + expect(r.covered, 'data cells in view answer another element at their centre').toEqual([]); + expect(r.actions.stick, 'the "⋮" column is not in the frozen zone').toBe('left'); + expect(r.frozen).toEqual(['name', '_actions']); + expect(r.inlineButtons, 'inline buttons are drawn although the table overflows').toBe(0); + expect(r.box.scrollbarHeight, 'the horizontal scrollbar takes no room').toBeGreaterThan(0); + expect(r.box.scrollbarColor, 'the scrollbar is transparent at rest').not.toMatch(/^transparent/); + expect(await lastColumnReachable(page, 'close_date'), 'the last column cannot be reached by scrolling').toBe(true); + await archiveFromMenu(page); + }); + } + + test('CONTROL: on the full list page nothing moves and nothing is covered', async ({ page }, testInfo) => { + test.setTimeout(120_000); + const c: Case = { name: 'fullPage1440', viewport: 1440, frame: FULL_PAGE, columns: COLUMNS }; + await mount(page, c); + const r = await readAtRest(page); + report(testInfo, c, r); + expect(r.box.scrollWidth - r.box.clientWidth, 'the fixture overflows the full page').toBeLessThanOrEqual(1); + expect(r.actions.stick).toBe('right'); + expect(r.order[r.order.length - 1]).toBe('_actions'); + expect(r.frozen).toEqual(['name']); + expect(r.overlap.px).toBeLessThanOrEqual(0.5); + expect(r.covered).toEqual([]); + await archiveFromMenu(page); + }); + + test('CONTROL: a narrow list whose columns fit keeps the "⋮" at the right edge', async ({ page }, testInfo) => { + test.setTimeout(120_000); + const c: Case = { name: 'aiPanelFew', viewport: 1167, frame: AI_PANEL_MAIN, columns: FEW_COLUMNS }; + await mount(page, c); + const r = await readAtRest(page); + report(testInfo, c, r); + expect(r.box.scrollWidth - r.box.clientWidth).toBeLessThanOrEqual(1); + expect(r.actions.stick).toBe('right'); + expect(r.frozen).toEqual(['name']); + expect(r.overlap.px).toBeLessThanOrEqual(0.5); + }); +}); From 2a640fac2f23e6c6446a1f07df41cf9f03087796 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 13:32:58 +0000 Subject: [PATCH 2/8] fix(grid): the row-actions column joins the frozen zone while the table overflows its box Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY Co-authored-by: Claude --- .../list-narrow-pinned-columns-35446.spec.ts | 6 +- .../src/renderers/complex/data-table.tsx | 37 +++++++++- ui/packages/plugin-grid/src/ObjectGrid.tsx | 49 +++++++++---- .../src/objectGridInlineActionFold.ts | 70 +++++++++++++++---- 4 files changed, 133 insertions(+), 29 deletions(-) diff --git a/ui/e2e/list-narrow-pinned-columns-35446.spec.ts b/ui/e2e/list-narrow-pinned-columns-35446.spec.ts index 0306e716503..93737d1a3ef 100644 --- a/ui/e2e/list-narrow-pinned-columns-35446.spec.ts +++ b/ui/e2e/list-narrow-pinned-columns-35446.spec.ts @@ -398,8 +398,9 @@ test.describe('app list in a narrowed main area — no fixed column covers a dat expect(r.actions.stick, 'the "⋮" column is not in the frozen zone').toBe('left'); expect(r.frozen).toEqual(['name', '_actions']); expect(r.inlineButtons, 'inline buttons are drawn although the table overflows').toBe(0); - expect(r.box.scrollbarHeight, 'the horizontal scrollbar takes no room').toBeGreaterThan(0); - expect(r.box.scrollbarColor, 'the scrollbar is transparent at rest').not.toMatch(/^transparent/); + // Headless Chromium draws no scrollbar at all (its room reads 0 either + // way), so the bar is read from its colour at rest. + expect(r.box.scrollbarColor, 'the scrollbar is transparent at rest').not.toMatch(/^(transparent|rgba\(0, 0, 0, 0\))/); expect(await lastColumnReachable(page, 'close_date'), 'the last column cannot be reached by scrolling').toBe(true); await archiveFromMenu(page); }); @@ -417,6 +418,7 @@ test.describe('app list in a narrowed main area — no fixed column covers a dat expect(r.frozen).toEqual(['name']); expect(r.overlap.px).toBeLessThanOrEqual(0.5); expect(r.covered).toEqual([]); + expect(r.box.scrollbarColor, 'a table that fits draws its scrollbar at rest').toMatch(/^(transparent|rgba\(0, 0, 0, 0\))/); await archiveFromMenu(page); }); diff --git a/ui/packages/components/src/renderers/complex/data-table.tsx b/ui/packages/components/src/renderers/complex/data-table.tsx index d0f38ee79ed..6bde1bf334a 100644 --- a/ui/packages/components/src/renderers/complex/data-table.tsx +++ b/ui/packages/components/src/renderers/complex/data-table.tsx @@ -1120,6 +1120,17 @@ function keepsBrowserContextMenu(target: HTMLElement, row: HTMLElement): boolean ); } +/** + * The scroll box's scrollbar while the table is wider than the box + * (objectstack#35446): drawn at rest in the theme's muted foreground, the + * colour the shared hover-only bar (`HOVER_SCROLLBAR_CLASSES`) turns on hover, + * and as thin. Marked important for the same reason that one is: a host may + * theme every scrollbar with an unlayered `*` rule. One complete literal: + * Tailwind builds only from scanned source text. + */ +const SIDEWAYS_SCROLLBAR_CLASSES = + '[scrollbar-width:thin]! [scrollbar-color:var(--color-muted-foreground)_transparent]!'; + /** * A right-pinned column: its sticky utilities arrive on `col.className` (the * auto-pinned row-actions column, and an author's `pinned: 'right'`, both @@ -2918,6 +2929,30 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => { return () => observer?.disconnect(); }, [overflowRight, columns, leadingCellCount, paginatedData.length]); + /** + * objectstack#35446 — while the table is wider than its box, the box draws + * its scrollbar at rest ({@link SIDEWAYS_SCROLLBAR_CLASSES}): columns out of + * view are announced by the bar itself, in a narrowed main area as anywhere, + * not only once the pointer is over the box. A table that fits keeps the + * shared hover-only bar (objectui#12708). A grouped sub-table + * (`disableInnerScroll`) scrolls in a shared ancestor and draws no bar. + */ + const [scrollsSideways, setScrollsSideways] = useState(false); + useLayoutEffect(() => { + const box = scrollBoxRef.current; + if (disableInnerScroll || !box) { + setScrollsSideways(false); + return; + } + const read = () => setScrollsSideways(box.scrollWidth - box.clientWidth > 1); + read(); + if (typeof ResizeObserver === 'undefined') return undefined; + const observer = new ResizeObserver(read); + observer.observe(box); + if (tableRef.current) observer.observe(tableRef.current); + return () => observer.disconnect(); + }, [disableInnerScroll, columns, paginatedData.length]); + const [rovingCell, setRovingCell] = useState<{ rowIndex: number; colIndex: number }>({ rowIndex: 0, colIndex: 0 }); const rovingRowIndex = Math.max(0, Math.min(rovingCell.rowIndex, paginatedData.length - 1)); const rovingColIndex = Math.max(0, Math.min(rovingCell.colIndex, columns.length - 1)); @@ -3435,7 +3470,7 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => { // sub-tables share one horizontal scrollbar with aligned columns. disableInnerScroll ? "overflow-visible" - : ["flex-1 min-h-0 overflow-auto [-webkit-overflow-scrolling:touch]", HOVER_SCROLLBAR_CLASSES], + : ["flex-1 min-h-0 overflow-auto [-webkit-overflow-scrolling:touch]", scrollsSideways ? SIDEWAYS_SCROLLBAR_CLASSES : HOVER_SCROLLBAR_CLASSES], !borderless && "rounded-md border", )}> {/* This div is already the (bounded) scroll container for BOTH axes — diff --git a/ui/packages/plugin-grid/src/ObjectGrid.tsx b/ui/packages/plugin-grid/src/ObjectGrid.tsx index 65a9d161079..4c522fc8f4d 100644 --- a/ui/packages/plugin-grid/src/ObjectGrid.tsx +++ b/ui/packages/plugin-grid/src/ObjectGrid.tsx @@ -1952,25 +1952,47 @@ export const ObjectGrid: React.FC = ({ const applyColumnChrome = (col: any) => withOneLineRichText(withSortability(applyDensity(col))); - const orderedColumns = hasPinnedColumns - ? [ - ...pinnedLeftCols.map(applyColumnChrome), - ...unpinnedCols.map(applyColumnChrome), - ...pinnedRightCols.map((col: any) => ({ - ...applyColumnChrome(col), - className: ['px-3', col.className, rightPinnedClasses].filter(Boolean).join(' '), - cellClassName: [rowHeightCellClass, col.cellClassName, rightPinnedCellClasses].filter(Boolean).join(' '), - })), - ] - : columnsWithActions.map(applyColumnChrome); - // Calculate frozenColumns: if the USER pinned columns, use their left-pinned // count; otherwise fall back to the schema default (freeze the first column). // The auto-pinned actions column is intentionally not counted here. - const effectiveFrozenColumns = hasUserPinnedColumns + const declaredFrozenColumns = hasUserPinnedColumns ? userLeftPinnedCount : (schema.frozenColumns ?? 1); + // objectstack#35446 — while the table overflows its box, the Actions column + // is drawn right after the frozen columns and frozen with them, instead of + // pinned to the right edge, where it sat over the data column reaching that + // edge at rest (`./objectGridInlineActionFold`). Every data column then + // scrolls and none is ever covered at rest. An author's own right pin is + // the author's layout and stays where it is. + const actionsColumn = pinnedRightCols.find((col: any) => col.accessorKey === '_actions'); + const actionsInFrozenZone = inlineActionFold.actionsFrozen && !!actionsColumn; + const scrollingColumns = [...pinnedLeftCols, ...unpinnedCols].map(applyColumnChrome); + const actionsFrozenAt = Math.min(declaredFrozenColumns, scrollingColumns.length); + const rightPinned = (col: any) => ({ + ...applyColumnChrome(col), + className: ['px-3', col.className, rightPinnedClasses].filter(Boolean).join(' '), + cellClassName: [rowHeightCellClass, col.cellClassName, rightPinnedCellClasses].filter(Boolean).join(' '), + }); + + const orderedColumns = actionsInFrozenZone + ? [ + ...scrollingColumns.slice(0, actionsFrozenAt), + { + ...applyColumnChrome(actionsColumn), + pinned: undefined, + className: ['px-3', actionsColumn.className].filter(Boolean).join(' '), + cellClassName: [rowHeightCellClass, actionsColumn.cellClassName].filter(Boolean).join(' '), + }, + ...scrollingColumns.slice(actionsFrozenAt), + ...pinnedRightCols.filter((col: any) => col !== actionsColumn).map(rightPinned), + ] + : hasPinnedColumns + ? [...scrollingColumns, ...pinnedRightCols.map(rightPinned)] + : columnsWithActions.map(applyColumnChrome); + + const effectiveFrozenColumns = actionsInFrozenZone ? actionsFrozenAt + 1 : declaredFrozenColumns; + // The floor. With no query to replay there is no honest "all N matching", so // the escalation is not offered — the same answer as a match set that does not // exist. This is what makes an unfiltered fan-out structurally unreachable @@ -3975,6 +3997,7 @@ export const ObjectGrid: React.FC = ({ ref={inlineActionFold.hostRef} className="flex flex-col flex-1 min-h-0" data-row-actions-inline={inlineActionFold.folded ? 'folded' : undefined} + data-row-actions-column={inlineActionFold.actionsFrozen ? 'frozen' : undefined} > diff --git a/ui/packages/plugin-grid/src/objectGridInlineActionFold.ts b/ui/packages/plugin-grid/src/objectGridInlineActionFold.ts index 53abf59026e..fb643f738af 100644 --- a/ui/packages/plugin-grid/src/objectGridInlineActionFold.ts +++ b/ui/packages/plugin-grid/src/objectGridInlineActionFold.ts @@ -1,6 +1,7 @@ /** * Whether `ObjectGrid` folds its inline primary row actions into the row's - * "⋮" menu (objectstack#33230). + * "⋮" menu (objectstack#33230), and whether the Actions column leaves the + * right edge for the frozen zone (objectstack#35446). * * The Actions column is pinned to the scroll box's right edge * (`./objectGridActionsColumn`), so while the table overflows the box the @@ -15,9 +16,19 @@ * moves to the top of its row's "⋮" menu (`planRowActionMenu`'s inline budget * of 0), so no action is dropped, and the pinned column shrinks to the * trigger. The buttons come back once the box is as wide as the table was with - * them. Where the table still overflows menu-only, the narrower pinned column - * still sits over the data at the box's edge, as on any list that scrolls - * sideways. + * them. + * + * Where the table still overflows menu-only, a column pinned to the right edge + * would sit over the data column that reaches that edge at rest (the amount + * column of a list in a main area narrowed by the AI panel, a small window or + * the record drawer). So while the table overflows, the Actions column joins + * the frozen zone instead (`actionsFrozen`): `ObjectGrid` draws it right after + * the frozen columns, which never cover a column at rest, and the data columns + * all scroll. It goes back to the right edge once the box is as wide as the + * table was when it moved. The move swaps the frozen zone's edge rule from the + * name column to the Actions column, a few pixels at most + * ({@link MOVE_WIDTH_SLACK_PX}), so the way back reads the width recorded + * before the move and the two placements cannot flip-flop. * * Every reading is taken once the table's size has held for two frames: the * table re-sizes its columns from what their cells drew over several passes, @@ -28,17 +39,28 @@ import * as React from 'react'; /** Sub-pixel rounding is not an overflow. */ const OVERFLOW_SLACK_PX = 1; +/** + * How much the move to the frozen zone may narrow the table (the edge rules it + * swaps). A frozen table that fits its box with more room than this to spare + * goes back to the right edge even before the box reaches the width recorded + * at the move, so a table that shrank while frozen is not held there. + */ +const MOVE_WIDTH_SLACK_PX = 4; /** Frames the table's size must hold before it is read. */ const SETTLED_FRAMES = 2; /** * Reads the grid's table scroll box under the element `hostRef` is attached - * to and answers whether the inline row actions fold. Starts unfolded, and - * starts again unfolded whenever `rows` or `columnsKey` change. + * to and answers whether the inline row actions fold and whether the Actions + * column is drawn in the frozen zone. Starts unfolded, and starts again + * unfolded whenever `rows` or `columnsKey` change; the column's placement is + * kept across those changes and read again from the widths they draw, so a + * refresh does not move it to the right edge and back. */ export function useInlineRowActionFold(rows: unknown, columnsKey: string): { hostRef: (element: HTMLElement | null) => void; folded: boolean; + actionsFrozen: boolean; } { const [host, setHost] = React.useState(null); const [folded, setFolded] = React.useState(false); @@ -46,6 +68,10 @@ export function useInlineRowActionFold(rows: unknown, columnsKey: string): { const foldedRef = React.useRef(false); // While folded: the table's width with the buttons, read when it folded. const unfoldedWidthRef = React.useRef(0); + const [actionsFrozen, setActionsFrozen] = React.useState(false); + const frozenRef = React.useRef(false); + // While frozen: the table's width with the column at the right edge. + const pinnedWidthRef = React.useRef(0); React.useLayoutEffect(() => { unfoldedWidthRef.current = 0; @@ -67,18 +93,36 @@ export function useInlineRowActionFold(rows: unknown, columnsKey: string): { foldedRef.current = next; setFolded(next); }; + const freeze = (next: boolean, tableWidth: number) => { + if (next === frozenRef.current) return; + frozenRef.current = next; + if (next) pinnedWidthRef.current = tableWidth; + setActionsFrozen(next); + }; const read = (box: HTMLElement) => { const boxWidth = box.clientWidth; if (boxWidth <= 0) return; + const tableWidth = box.scrollWidth; + const overflow = tableWidth - boxWidth; if (foldedRef.current) { - if (boxWidth >= unfoldedWidthRef.current) decide(false); + if (boxWidth >= unfoldedWidthRef.current) { + // The buttons fit again, so the table fits at the right edge too. + freeze(false, tableWidth); + decide(false); + return; + } + } else if (overflow > OVERFLOW_SLACK_PX && box.querySelector('[data-testid^="row-action-inline-"]')) { + // Fold first: the column's placement is read from the menu-only face. + unfoldedWidthRef.current = tableWidth; + decide(true); return; } - const tableWidth = box.scrollWidth; - if (tableWidth - boxWidth <= OVERFLOW_SLACK_PX) return; - if (!box.querySelector('[data-testid^="row-action-inline-"]')) return; - unfoldedWidthRef.current = tableWidth; - decide(true); + if (!box.querySelector('th[data-column-key="_actions"]')) return; + if (!frozenRef.current) { + if (overflow > OVERFLOW_SLACK_PX) freeze(true, tableWidth); + } else if (boxWidth >= pinnedWidthRef.current || overflow < -MOVE_WIDTH_SLACK_PX) { + freeze(false, tableWidth); + } }; const tick = () => { frame = 0; @@ -128,5 +172,5 @@ export function useInlineRowActionFold(rows: unknown, columnsKey: string): { }; }, [host]); - return { hostRef: setHost, folded }; + return { hostRef: setHost, folded, actionsFrozen }; } From 4c89023176617f6bc223ef2aa49286c4d2ae24c7 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 13:52:16 +0000 Subject: [PATCH 3/8] test(grid): pin the row-actions column's frozen-zone placement and the at-rest scrollbar Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY Co-authored-by: Claude --- .../related-list-pinned-actions-width.spec.ts | 7 ++- .../data-table-scroll-shadow-12463.test.tsx | 47 +++++++++++++++ .../src/__tests__/row-action-sticky.test.tsx | 59 +++++++++++++++++++ .../src/objectGridInlineActionFold.ts | 4 +- 4 files changed, 113 insertions(+), 4 deletions(-) diff --git a/ui/e2e/related-list-pinned-actions-width.spec.ts b/ui/e2e/related-list-pinned-actions-width.spec.ts index 9da687ba241..50ee178dc86 100644 --- a/ui/e2e/related-list-pinned-actions-width.spec.ts +++ b/ui/e2e/related-list-pinned-actions-width.spec.ts @@ -397,10 +397,11 @@ test.describe('enlarged related list in a record drawer — the pinned Actions c report(testInfo, c, r); expect(r.folded).toBe(true); expect(r.inlineButtons).toBe(0); - // Still wider than the drawer: the pinned column sits at the box's edge - // over whichever column scrolls under it, as on any list that scrolls - // sideways. A scroll to the end shows Status whole. + // Still wider than the drawer: the Actions column leaves the right edge + // for the frozen zone beside the name column (objectstack#35446), and a + // scroll to the end shows Status whole. expect(r.box.scrollWidth).toBeGreaterThan(r.box.clientWidth); + expect(r.actions.left, 'the Actions column still sits at the right edge').toBeLessThan(r.box.clientWidth / 2); const end = await page.evaluate(async () => { const box = document.querySelector('[data-table-scroll-box]')!; box.scrollLeft = box.scrollWidth; diff --git a/ui/packages/components/src/renderers/complex/__tests__/data-table-scroll-shadow-12463.test.tsx b/ui/packages/components/src/renderers/complex/__tests__/data-table-scroll-shadow-12463.test.tsx index f5b6dc5b8c6..07621302e61 100644 --- a/ui/packages/components/src/renderers/complex/__tests__/data-table-scroll-shadow-12463.test.tsx +++ b/ui/packages/components/src/renderers/complex/__tests__/data-table-scroll-shadow-12463.test.tsx @@ -140,3 +140,50 @@ describe('data-table scroll box, sticky columns and right-edge shadow (objectui# expect(queryByTestId('data-table-scroll-shadow-right')).toBeNull(); }); }); + +/** + * objectstack#35446 — while the table is wider than its box the box draws its + * scrollbar at rest, so columns out of view are announced without the pointer + * over the box; a table that fits keeps the shared hover-only bar + * (objectui#12708). The box's geometry is stubbed before the table mounts, + * because the read is taken at mount and on resize, not on scroll. + */ +describe('data-table scrollbar at rest while the table scrolls sideways (objectstack#35446)', () => { + const AT_REST = '[scrollbar-color:var(--color-muted-foreground)_transparent]!'; + const TRANSPARENT = '[scrollbar-color:transparent_transparent]!'; + + function stubBoxWidths(scrollWidth: number, clientWidth: number): () => void { + const proto = HTMLElement.prototype; + const isBox = (el: HTMLElement) => el.hasAttribute('data-table-scroll-box'); + Object.defineProperty(proto, 'scrollWidth', { configurable: true, get(this: HTMLElement) { return isBox(this) ? scrollWidth : 0; } }); + Object.defineProperty(proto, 'clientWidth', { configurable: true, get(this: HTMLElement) { return isBox(this) ? clientWidth : 0; } }); + return () => { + delete (proto as unknown as Record).scrollWidth; + delete (proto as unknown as Record).clientWidth; + }; + } + + it('a table wider than its box draws the bar at rest', () => { + const restore = stubBoxWidths(1400, 700); + try { + const { getByTestId } = renderTable(baseSchema); + const classes = getByTestId('data-table-scroll-box').className.split(/\s+/); + expect(classes).toContain(AT_REST); + expect(classes).not.toContain(TRANSPARENT); + } finally { + restore(); + } + }); + + it('CONTROL: a table that fits keeps the hover-only bar', () => { + const restore = stubBoxWidths(700, 700); + try { + const { getByTestId } = renderTable(baseSchema); + const classes = getByTestId('data-table-scroll-box').className.split(/\s+/); + expect(classes).toContain(TRANSPARENT); + expect(classes).not.toContain(AT_REST); + } finally { + restore(); + } + }); +}); diff --git a/ui/packages/plugin-grid/src/__tests__/row-action-sticky.test.tsx b/ui/packages/plugin-grid/src/__tests__/row-action-sticky.test.tsx index 1acbcfcff6a..5bd2a7175cd 100644 --- a/ui/packages/plugin-grid/src/__tests__/row-action-sticky.test.tsx +++ b/ui/packages/plugin-grid/src/__tests__/row-action-sticky.test.tsx @@ -87,3 +87,62 @@ describe('row-actions column sticky-right', () => { await waitFor(() => expect(screen.getAllByTestId('row-action-inline-open').length).toBe(ROWS.length)); }); }); + +/** + * objectstack#35446 — while the table overflows its box, the row-actions + * column leaves the right edge, where it sat over the data column reaching + * that edge at rest, and joins the frozen zone right after the name column; + * a table that fits keeps it pinned right (the cases above). jsdom does no + * layout, so the box's widths are stubbed; the geometry itself is pinned in + * Chromium by `e2e/list-narrow-pinned-columns-35446.spec.ts`. + */ +describe('row-actions column in the frozen zone while the table overflows (objectstack#35446)', () => { + function stubBoxWidths(scrollWidth: number, clientWidth: number): () => void { + const proto = HTMLElement.prototype; + const isBox = (el: HTMLElement) => el.hasAttribute('data-table-scroll-box'); + Object.defineProperty(proto, 'scrollWidth', { configurable: true, get(this: HTMLElement) { return isBox(this) ? scrollWidth : 0; } }); + Object.defineProperty(proto, 'clientWidth', { configurable: true, get(this: HTMLElement) { return isBox(this) ? clientWidth : 0; } }); + return () => { + delete (proto as unknown as Record).scrollWidth; + delete (proto as unknown as Record).clientWidth; + }; + } + + const headerKeys = () => + Array.from(document.querySelectorAll('thead th')) + .map((th) => th.getAttribute('data-column-key')) + .filter(Boolean); + + it('draws the actions column after the frozen name column, frozen with it, not pinned right', async () => { + const restore = stubBoxWidths(1000, 600); + try { + renderGrid({ rowActionDefs: [{ name: 'archive', label: 'Archive' }] }); + await waitFor(() => expect(document.querySelector('[data-row-actions-column="frozen"]')).not.toBeNull()); + expect(headerKeys()).toEqual(['name', '_actions', 'amount']); + const actionsHeader = document.querySelector('th[data-column-key="_actions"]') as HTMLElement; + expect(actionsHeader.className).toContain('sticky'); + expect(actionsHeader.className).not.toContain('right-0'); + const actionsCell = screen.getAllByTestId('row-action-trigger')[0].closest('td')!; + expect(actionsCell.className).toContain('sticky'); + expect(actionsCell.className).not.toContain('right-0'); + // The name column stays frozen ahead of it. + expect(screen.getByText('Alice').closest('td')!.className).toContain('sticky'); + expect(document.querySelector('td.right-0')).toBeNull(); + } finally { + restore(); + } + }); + + it('folds an inline primary action into the row menu first, then moves the column', async () => { + const restore = stubBoxWidths(1000, 600); + try { + renderGrid(); + await waitFor(() => expect(document.querySelector('[data-row-actions-column="frozen"]')).not.toBeNull()); + expect(document.querySelector('[data-row-actions-inline="folded"]')).not.toBeNull(); + expect(screen.queryAllByTestId('row-action-inline-open')).toHaveLength(0); + expect(headerKeys()).toEqual(['name', '_actions', 'amount']); + } finally { + restore(); + } + }); +}); diff --git a/ui/packages/plugin-grid/src/objectGridInlineActionFold.ts b/ui/packages/plugin-grid/src/objectGridInlineActionFold.ts index fb643f738af..e02f996eb02 100644 --- a/ui/packages/plugin-grid/src/objectGridInlineActionFold.ts +++ b/ui/packages/plugin-grid/src/objectGridInlineActionFold.ts @@ -112,9 +112,11 @@ export function useInlineRowActionFold(rows: unknown, columnsKey: string): { return; } } else if (overflow > OVERFLOW_SLACK_PX && box.querySelector('[data-testid^="row-action-inline-"]')) { - // Fold first: the column's placement is read from the menu-only face. + // Fold first: the column's placement is read from the menu-only face, + // once it has drawn, whether or not the fold resizes the box. unfoldedWidthRef.current = tableWidth; decide(true); + schedule(); return; } if (!box.querySelector('th[data-column-key="_actions"]')) return; From 8f9b54adb5fc7947ae2742b9c2802f7481aafaf5 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 14:06:45 +0000 Subject: [PATCH 4/8] fix(grid): type the frozen-zone column read and add the changeset Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY Co-authored-by: Claude --- .changeset/35446-list-narrow-fixed-columns.md | 13 +++++++++++++ ui/packages/plugin-grid/src/ObjectGrid.tsx | 15 +++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 .changeset/35446-list-narrow-fixed-columns.md diff --git a/.changeset/35446-list-narrow-fixed-columns.md b/.changeset/35446-list-narrow-fixed-columns.md new file mode 100644 index 00000000000..8489e063a22 --- /dev/null +++ b/.changeset/35446-list-narrow-fixed-columns.md @@ -0,0 +1,13 @@ +--- +'@object-ui/plugin-grid': patch +'@object-ui/components': patch +--- + +fix(grid): a list in a narrowed main area keeps every data cell clear of its fixed columns and shows its horizontal scrollbar + +Clause-②: no +Metadata-protocol: none + +- **Row actions column.** While a list's table is wider than its box (the AI panel docked, a small window, the record drawer open), the row actions column (the row's "⋮") is drawn right after the frozen name column and frozen with it, instead of pinned to the right edge, where it covered the data column reaching that edge (an amount cut to 「¥94,0」). Every data column then scrolls sideways under the frozen columns, and none is covered at rest. Once the box is wide enough for the whole table again, the column goes back to the right edge, so a list that fits looks as before. Inline primary row actions still fold into the "⋮" menu first, as before. Columns an author pinned to the right stay where the author put them; the grouped list is unchanged. +- **Horizontal scrollbar.** A table wider than its box draws its scrollbar at rest instead of only while the pointer is over it, so columns out of view are announced. A table that fits keeps the scrollbar that shows on hover. +- No column is hidden and no column configuration changes. diff --git a/ui/packages/plugin-grid/src/ObjectGrid.tsx b/ui/packages/plugin-grid/src/ObjectGrid.tsx index 4c522fc8f4d..6345cbb3d61 100644 --- a/ui/packages/plugin-grid/src/ObjectGrid.tsx +++ b/ui/packages/plugin-grid/src/ObjectGrid.tsx @@ -1974,16 +1974,19 @@ export const ObjectGrid: React.FC = ({ className: ['px-3', col.className, rightPinnedClasses].filter(Boolean).join(' '), cellClassName: [rowHeightCellClass, col.cellClassName, rightPinnedCellClasses].filter(Boolean).join(' '), }); + // The same cell padding as at the right edge; the frozen zone's own sticky + // classes, offset and edge rule come from `data-table`. + const inFrozenZone = (col: any) => ({ + ...applyColumnChrome(col), + pinned: undefined, + className: ['px-3', col.className].filter(Boolean).join(' '), + cellClassName: [rowHeightCellClass, col.cellClassName].filter(Boolean).join(' '), + }); const orderedColumns = actionsInFrozenZone ? [ ...scrollingColumns.slice(0, actionsFrozenAt), - { - ...applyColumnChrome(actionsColumn), - pinned: undefined, - className: ['px-3', actionsColumn.className].filter(Boolean).join(' '), - cellClassName: [rowHeightCellClass, actionsColumn.cellClassName].filter(Boolean).join(' '), - }, + inFrozenZone(actionsColumn), ...scrollingColumns.slice(actionsFrozenAt), ...pinnedRightCols.filter((col: any) => col !== actionsColumn).map(rightPinned), ] From 8c4a9542d6f20c9f891236032f4daa91fa5de1ea Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 19 Nov 2026 15:15:32 +0000 Subject: [PATCH 5/8] fix(console): the list page header drops its description and folds its actions while narrow Claude-Session: https://claude.ai/code/session_01Utp6CbSphdunq2aJq7ktuY Co-authored-by: Claude --- .../app-shell/src/layout/PageHeader.tsx | 56 +++++++++++++++--- .../PageHeader.actionsFold-12705.test.tsx | 59 ++++++++++++++++++- .../src/views/objectViewPageHeader.tsx | 10 ++++ 3 files changed, 116 insertions(+), 9 deletions(-) diff --git a/ui/packages/app-shell/src/layout/PageHeader.tsx b/ui/packages/app-shell/src/layout/PageHeader.tsx index f2b2303e4f5..ce128f83a7a 100644 --- a/ui/packages/app-shell/src/layout/PageHeader.tsx +++ b/ui/packages/app-shell/src/layout/PageHeader.tsx @@ -35,6 +35,12 @@ * the header is too narrow for `actions` and its text, it draws that instead, * so the actions fold before the title or the description is cut: * [icon] Title [kind] | the whole description [refresh] [primary] [⋯] + * + * The compact form — a page may opt in with `compactBelow` (objectstack#35446): + * while the one-row header is narrower than that, it drops the description and + * draws `foldedActions` whatever the text needs, so a main area narrowed by a + * docked panel, a small window or the record drawer gets a short header row: + * [icon] Title [kind] [refresh] [primary] [⋯] */ import * as React from 'react'; @@ -140,6 +146,17 @@ export interface ConsolePageHeaderProps { * trade the page's actions for its description. */ foldedActions?: React.ReactNode; + /** + * Opt-in compact form for a narrow header (objectstack#35446): while the + * one-row header is narrower than this many pixels, the description (and + * the hairline before it) is not drawn and `foldedActions`, when given, is + * drawn in place of `actions`. At this width and above the header behaves + * exactly as without it. Read from the header's own width, never the + * viewport's, so any narrowing of the main area counts. Setup's posture, + * whose description sits on its own line, ignores it. A page that passes + * nothing keeps today's header at every width. + */ + compactBelow?: number; /** * CSS color used to tint the top hairline, icon chip background, and * icon stroke. Defaults to the Shadcn `--primary` token so the header @@ -184,6 +201,7 @@ export function PageHeader({ refresh, actions, foldedActions, + compactBelow, accentColor, sticky = false, className, @@ -198,8 +216,12 @@ export function PageHeader({ // objectui#12705 — the actions fold before the text is cut. const canFold = foldedActions != null && foldedActions !== false; - const { rootRef, textRef, descriptionRef, clusterRef, folded } = useActionsFold(canFold, setup); - const drawnActions = canFold && folded ? foldedActions : actions; + const { rootRef, textRef, descriptionRef, clusterRef, folded, compact } = useActionsFold( + canFold, + setup, + setup ? undefined : compactBelow, + ); + const drawnActions = canFold && (folded || compact) ? foldedActions : actions; const refreshButton = refresh ? (