From dc656ee8472d519e34fc988478df13fef8ee563f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 05:19:14 +0000 Subject: [PATCH 1/7] test(plugin-detail): pin the body table in the preview drawer's details column settling its column cap Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude --- .../RelatedList.bodyTable-27055.test.tsx | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx b/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx index 59c3d69ec5f..482b291fcb3 100644 --- a/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx @@ -634,3 +634,141 @@ describe('RelatedList — a body table draws the list\'s dense rows (objectstack expect(tableRoot()?.className ?? '').not.toContain('[&_tbody_td]:h-8'); }); }); + +describe('RelatedList — a body table in the record preview drawer settles its columns (objectstack#37212)', () => { + // The preview drawer opens 460 px wide, which leaves its details column a + // 326 px scroll box: the width at which this list's column cap read the + // table data-table drew for the PREVIOUS cap (data-table adopts a new + // `columns` prop a commit later) and flipped 1 -> 2 -> 1 until React gave + // up with "Maximum update depth exceeded" (#185). The full page's details + // column is wide enough that nothing is left out, so it never flipped. + // + // The layout below is the browser's, reduced to what the cap reads: a data + // header cell is as wide as its inline min-width (else its own natural + // width), the row-actions cell is 66 px, and a table narrower than its box + // stretches to fill it, the actions cell taking its share. + const ACTIONS_PX = 66; + const NATURAL_PX: Record = { product: 104, tier: 156, quantity: 112, total: 120 }; + let boxPx = 326; + const proto = HTMLElement.prototype; + const saved = { + scrollWidth: Object.getOwnPropertyDescriptor(proto, 'scrollWidth'), + clientWidth: Object.getOwnPropertyDescriptor(proto, 'clientWidth'), + getBoundingClientRect: Object.getOwnPropertyDescriptor(proto, 'getBoundingClientRect'), + }; + const dataCellPx = (th: HTMLElement) => + parseFloat(th.style.minWidth) || NATURAL_PX[th.getAttribute('data-column-key') ?? ''] || 0; + const tableOf = (box: HTMLElement) => { + const heads = Array.from(box.querySelectorAll('thead th[data-column-key]')); + const data = heads.reduce((sum, th) => sum + dataCellPx(th), 0); + const natural = data + ACTIONS_PX; + const stretch = Math.max(0, boxPx - natural); + return { natural, actionsPx: ACTIONS_PX + (stretch * ACTIONS_PX) / natural }; + }; + beforeAll(() => { + Object.defineProperty(proto, 'clientWidth', { + configurable: true, + get(this: HTMLElement) { + return this.hasAttribute('data-table-scroll-box') ? boxPx : 0; + }, + }); + Object.defineProperty(proto, 'scrollWidth', { + configurable: true, + get(this: HTMLElement) { + return this.hasAttribute('data-table-scroll-box') ? Math.max(boxPx, tableOf(this).natural) : 0; + }, + }); + Object.defineProperty(proto, 'getBoundingClientRect', { + configurable: true, + value(this: HTMLElement) { + const box = this.tagName === 'TH' ? this.closest('[data-table-scroll-box]') : null; + const width = !box ? 0 : this.hasAttribute('data-column-key') ? dataCellPx(this) : tableOf(box).actionsPx; + return { x: 0, y: 0, top: 0, left: 0, bottom: 0, right: width, width, height: 0, toJSON() {} } as DOMRect; + }, + }); + }); + afterAll(() => { + for (const [key, descriptor] of Object.entries(saved)) { + if (descriptor) Object.defineProperty(proto, key, descriptor); + else delete (proto as any)[key]; + } + }); + afterEach(() => { + boxPx = 326; + vi.restoreAllMocks(); + }); + + // The first column's cells store a long value and draw a short label, so the + // table's first estimate of it (from the stored value) is wider than the + // width it asks for once drawn — the move that set the cap flipping. + const lineFields = { + product: { + type: 'select', + label: 'Product', + options: [{ value: 'enterprise_license_annual_plan', label: 'License' }], + }, + tier: { type: 'text', label: 'Tier level' }, + quantity: { type: 'number', label: 'Quantity' }, + total: { type: 'currency', label: 'Total', currencyConfig: { currencyMode: 'fixed', defaultCurrency: 'USD' } }, + }; + const lineRows = [ + { id: 'l1', product: 'enterprise_license_annual_plan', tier: 'ent', quantity: 2, total: 20 }, + { id: 'l2', product: 'enterprise_license_annual_plan', tier: 'std', quantity: 3, total: 45 }, + ]; + + function renderLines() { + const errors = vi.spyOn(console, 'error').mockImplementation(() => {}); + render( + + + ({ field, label: (lineFields as any)[field].label }))} + data={lineRows} + onRowEdit={vi.fn()} + dataSource={{ + find: vi.fn(async () => lineRows), + getObjectSchema: vi.fn(async () => ({ name: 'opportunity_line_item', fields: lineFields })), + } as any} + /> + + , + ); + return errors; + } + const headerKeys = () => + Array.from(document.querySelectorAll('thead th[data-column-key]')).map((th) => th.getAttribute('data-column-key')); + const updateDepthErrors = (errors: ReturnType) => + errors.mock.calls.filter((call) => /Maximum update depth|#185/.test(call.map(String).join(' '))); + + it('in the 326 px details column of the 460 px preview: the table draws, and the cap settles on the leading columns that fit', async () => { + const errors = renderLines(); + await waitFor(() => expect(document.querySelector('[data-body-table-columns-omitted]')).not.toBeNull()); + // Let every read the table's re-draws trigger run out. + await new Promise((resolve) => setTimeout(resolve, 50)); + expect(screen.queryByText(/failed to render/i)).toBeNull(); + expect(updateDepthErrors(errors)).toEqual([]); + // Settled: what the list hands is what the table draws, a leading run. + const host = document.querySelector('[data-body-table-overflow]') as HTMLElement; + const omitted = Number(host.getAttribute('data-body-table-columns-omitted')); + const keys = Object.keys(lineFields); + expect(headerKeys()).toEqual(keys.slice(0, keys.length - omitted)); + expect(screen.getAllByText('License').length).toBeGreaterThan(0); + }); + + it('CONTROL — the full page\'s wide details column: every column drawn, none left out, no error', async () => { + boxPx = 1052; + const errors = renderLines(); + await waitFor(() => expect(screen.getAllByText('License').length).toBeGreaterThan(0)); + await new Promise((resolve) => setTimeout(resolve, 50)); + expect(screen.queryByText(/failed to render/i)).toBeNull(); + expect(updateDepthErrors(errors)).toEqual([]); + expect(document.querySelector('[data-body-table-columns-omitted]')).toBeNull(); + expect(headerKeys()).toEqual(Object.keys(lineFields)); + }); +}); From 35079023b0b03d75bf2a567b9f8748db256f750c Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 05:29:07 +0000 Subject: [PATCH 2/7] test(plugin-detail): the drawer pin fetches its rows, as the preview drawer does Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude --- .../src/__tests__/RelatedList.bodyTable-27055.test.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx b/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx index 482b291fcb3..89f4d0cc509 100644 --- a/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx @@ -729,10 +729,12 @@ describe('RelatedList — a body table in the record preview drawer settles its referenceField="opportunity" parentId="o1" columns={Object.keys(lineFields).map((field) => ({ field, label: (lineFields as any)[field].label }))} - data={lineRows} onRowEdit={vi.fn()} dataSource={{ - find: vi.fn(async () => lineRows), + // The rows arrive from the data source after the schema, as in + // the drawer: the table first draws them in the commit whose + // read first measures it. + find: vi.fn(() => new Promise((resolve) => setTimeout(() => resolve(lineRows), 20))), getObjectSchema: vi.fn(async () => ({ name: 'opportunity_line_item', fields: lineFields })), } as any} /> From 8287ecfb105cc13a696b03fa540991211e99f002 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 05:29:28 +0000 Subject: [PATCH 3/7] fix(plugin-detail): a body table's column cap reads only the table drawn for it The cap's read re-ran in the commit that changed the cap and measured the table data-table still drew for the previous cap (it adopts a new columns prop a render later). In the record preview drawer's narrow details column that read flipped the cap 1 -> 2 -> 1 on every commit until React stopped it with Maximum update depth exceeded. The read now waits for the table to draw the columns it was handed; the table's re-draw reads again. Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude --- ui/packages/plugin-detail/src/RelatedList.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ui/packages/plugin-detail/src/RelatedList.tsx b/ui/packages/plugin-detail/src/RelatedList.tsx index b4c79e4a546..603b38b6098 100644 --- a/ui/packages/plugin-detail/src/RelatedList.tsx +++ b/ui/packages/plugin-detail/src/RelatedList.tsx @@ -4077,6 +4077,14 @@ export const RelatedList: React.FC = ({ const keys = readColumnKeys(bodyTableColumnKeysKey); const watch = (box: HTMLElement) => { const read = () => { + // objectstack#37212 — a table that still draws an earlier hand-over + // (another leading run of these columns: the table adopts the columns + // it is handed a render later) is measured for that cap, not this one, + // and judging this cap by it flips the cap on every commit. Wait for + // the table to draw what it was handed; its re-draw reads again. + const drawn = Array.from(box.querySelectorAll('thead th[data-column-key]'), (th) => th.getAttribute('data-column-key')); + const handed = bodyTableColumnCap ?? keys.length; + if (drawn.length !== handed && drawn.every((key, index) => key === keys[index])) return; // objectstack#35742 — the columns that fit whole: the box's width // less the cells that are no column (the row actions), against the // width each column asks for. @@ -4096,7 +4104,7 @@ export const RelatedList: React.FC = ({ setBodyTableOverflows(box.scrollWidth - box.clientWidth > 1); }; read(); - // The table settles its columns a render after it is handed fewer: + // The table settles its columns a render after it is handed others: // read again when its cells change. if (typeof MutationObserver !== 'undefined') { cells = new MutationObserver(read); From 3428792fd94a187e6ef4df9d43240b35075192a9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 05:32:32 +0000 Subject: [PATCH 4/7] chore(changeset): patch for the drawer body table column cap Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude --- .changeset/37212-drawer-body-table-column-cap.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .changeset/37212-drawer-body-table-column-cap.md diff --git a/.changeset/37212-drawer-body-table-column-cap.md b/.changeset/37212-drawer-body-table-column-cap.md new file mode 100644 index 00000000000..3c75105d3d3 --- /dev/null +++ b/.changeset/37212-drawer-body-table-column-cap.md @@ -0,0 +1,10 @@ +--- +'@object-ui/plugin-detail': patch +--- + +fix(plugin-detail): a related table in the record preview drawer draws instead of failing with "Maximum update depth exceeded" + +Clause-②: no +Metadata-protocol: none + +A record's related table drawn in the details of the record preview drawer (for example an opportunity's line items) could fail with `Component "data-table" failed to render` and React error #185, while the record's full page drew the same table. The table leaves out the columns that do not fit whole in its column, and re-reads that choice when it changes. The re-read measured the table still drawn for the previous choice, because the table adopts a new set of columns a render later. In the drawer's narrow details column that read changed its answer on every render: one column, then two, then one again. The read now waits until the table draws the columns it was handed, and the table's next draw reads again. A table wide enough for every column, as on the full page, is unchanged. From 1cb2c044f055146ef94b7dea356a940dfa66738a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 06:10:45 +0000 Subject: [PATCH 5/7] test(plugin-detail): type the drawer pin's console-error filter Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude --- .../src/__tests__/RelatedList.bodyTable-27055.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx b/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx index 89f4d0cc509..fe627b77354 100644 --- a/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx @@ -745,8 +745,8 @@ describe('RelatedList — a body table in the record preview drawer settles its } const headerKeys = () => Array.from(document.querySelectorAll('thead th[data-column-key]')).map((th) => th.getAttribute('data-column-key')); - const updateDepthErrors = (errors: ReturnType) => - errors.mock.calls.filter((call) => /Maximum update depth|#185/.test(call.map(String).join(' '))); + const updateDepthErrors = (errors: { mock: { calls: unknown[][] } }) => + errors.mock.calls.filter((call: unknown[]) => /Maximum update depth|#185/.test(call.map(String).join(' '))); it('in the 326 px details column of the 460 px preview: the table draws, and the cap settles on the leading columns that fit', async () => { const errors = renderLines(); From e1b242fed2319a9e23d5fe70206cb41f9b517605 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 07:45:23 +0000 Subject: [PATCH 6/7] fix(plugin-detail): a body table's cap read skips only the table's adoption lag, not a column it hid itself The read skipped any shorter leading run the table drew, so a column hidden from the header menu froze the cap and the overflow cue. It now skips only while the table still draws the hand-over it adopted last. Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude --- ui/packages/plugin-detail/src/RelatedList.tsx | 19 +++++++++----- .../RelatedList.bodyTable-27055.test.tsx | 26 +++++++++++++++++-- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/ui/packages/plugin-detail/src/RelatedList.tsx b/ui/packages/plugin-detail/src/RelatedList.tsx index 603b38b6098..c199589f7aa 100644 --- a/ui/packages/plugin-detail/src/RelatedList.tsx +++ b/ui/packages/plugin-detail/src/RelatedList.tsx @@ -3665,6 +3665,9 @@ export const RelatedList: React.FC = ({ // key, so a column left out is still counted when the box grows. const [bodyTableColumnCap, setBodyTableColumnCap] = React.useState(null); const bodyTableColumnWidths = React.useRef(new Map()); + // objectstack#37212 — how many columns the table last drew as handed: a + // hand-over it has adopted. `null` until it has drawn one. + const bodyTableAdoptedCount = React.useRef(null); const bodyTableColumnKeysKey = React.useMemo( () => JSON.stringify((tableColumns ?? []).map((col: any) => String(col?.accessorKey ?? ''))), [tableColumns], @@ -3672,6 +3675,7 @@ export const RelatedList: React.FC = ({ // A different column set is measured afresh, every column drawn. React.useLayoutEffect(() => { bodyTableColumnWidths.current.clear(); + bodyTableAdoptedCount.current = null; setBodyTableColumnCap(null); }, [bodyTableColumnKeysKey]); const bodyTableColumnsOmitted = bodyTable && bodyTableColumnCap !== null; @@ -4077,14 +4081,17 @@ export const RelatedList: React.FC = ({ const keys = readColumnKeys(bodyTableColumnKeysKey); const watch = (box: HTMLElement) => { const read = () => { - // objectstack#37212 — a table that still draws an earlier hand-over - // (another leading run of these columns: the table adopts the columns - // it is handed a render later) is measured for that cap, not this one, - // and judging this cap by it flips the cap on every commit. Wait for - // the table to draw what it was handed; its re-draw reads again. + // objectstack#37212 — the table adopts the columns it is handed a + // render later. While it still draws the hand-over it adopted last (the + // same leading run of these columns), it is measured for that cap, not + // this one, and judging this cap by it flips the cap on every commit: + // skip that read; its re-draw reads again. A table that draws a run of + // its own choosing (a column hidden from its header menu) is read. const drawn = Array.from(box.querySelectorAll('thead th[data-column-key]'), (th) => th.getAttribute('data-column-key')); const handed = bodyTableColumnCap ?? keys.length; - if (drawn.length !== handed && drawn.every((key, index) => key === keys[index])) return; + const leadingRun = drawn.every((key, index) => key === keys[index]); + if (leadingRun && drawn.length === handed) bodyTableAdoptedCount.current = handed; + else if (leadingRun && drawn.length === bodyTableAdoptedCount.current) return; // objectstack#35742 — the columns that fit whole: the box's width // less the cells that are no column (the row actions), against the // width each column asks for. diff --git a/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx b/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx index fe627b77354..2e6ed265855 100644 --- a/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx +++ b/ui/packages/plugin-detail/src/__tests__/RelatedList.bodyTable-27055.test.tsx @@ -25,7 +25,7 @@ * an empty body table draws its headers and one empty row with the add entry. */ import { describe, it, expect, vi, beforeAll, afterAll, afterEach } from 'vitest'; -import { render, screen, waitFor, fireEvent } from '@testing-library/react'; +import { act, render, screen, waitFor, fireEvent } from '@testing-library/react'; import '@testing-library/jest-dom'; import React from 'react'; import { RecordContextProvider } from '@object-ui/react'; @@ -748,7 +748,7 @@ describe('RelatedList — a body table in the record preview drawer settles its const updateDepthErrors = (errors: { mock: { calls: unknown[][] } }) => errors.mock.calls.filter((call: unknown[]) => /Maximum update depth|#185/.test(call.map(String).join(' '))); - it('in the 326 px details column of the 460 px preview: the table draws, and the cap settles on the leading columns that fit', async () => { + it('in the 326 px details column of the 460 px preview: the table draws, and the cap settles on a leading run of the columns', async () => { const errors = renderLines(); await waitFor(() => expect(document.querySelector('[data-body-table-columns-omitted]')).not.toBeNull()); // Let every read the table's re-draws trigger run out. @@ -763,6 +763,28 @@ describe('RelatedList — a body table in the record preview drawer settles its expect(screen.getAllByText('License').length).toBeGreaterThan(0); }); + it('a column hidden from the header menu is the table\'s own choice: a later narrowing is still read (cap and overflow cue)', async () => { + boxPx = 1052; + renderLines(); + await waitFor(() => expect(headerKeys()).toEqual(Object.keys(lineFields))); + const total = document.querySelector('thead th[data-column-key="total"]') as HTMLElement; + fireEvent.contextMenu(total); + fireEvent.click(await screen.findByText('Hide column')); + await waitFor(() => expect(headerKeys()).toEqual(['product', 'tier', 'quantity'])); + const host = document.querySelector('[data-body-table-overflow]') as HTMLElement; + expect(host.hasAttribute('data-body-table-columns-omitted')).toBe(false); + // Narrowed to the drawer's details column. jsdom reports no resize; a + // change of the box's content asks the read the same question. + boxPx = 326; + const box = document.querySelector('[data-table-scroll-box]') as HTMLElement; + act(() => { + box.appendChild(document.createElement('span')); + }); + await waitFor(() => expect(host.getAttribute('data-body-table-columns-omitted')).not.toBeNull()); + expect(headerKeys().length).toBeLessThan(3); + expect(host.getAttribute('data-body-table-overflow')).toBe('true'); + }); + it('CONTROL — the full page\'s wide details column: every column drawn, none left out, no error', async () => { boxPx = 1052; const errors = renderLines(); From 40088303876739080bc9d8c2709ff606e35290ef Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 25 Nov 2026 08:18:29 +0000 Subject: [PATCH 7/7] chore(changeset): say what the body table's cap read skips and still reads Claude-Session: https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D Co-authored-by: Claude --- .changeset/37212-drawer-body-table-column-cap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/37212-drawer-body-table-column-cap.md b/.changeset/37212-drawer-body-table-column-cap.md index 3c75105d3d3..d567439e814 100644 --- a/.changeset/37212-drawer-body-table-column-cap.md +++ b/.changeset/37212-drawer-body-table-column-cap.md @@ -7,4 +7,4 @@ fix(plugin-detail): a related table in the record preview drawer draws instead o Clause-②: no Metadata-protocol: none -A record's related table drawn in the details of the record preview drawer (for example an opportunity's line items) could fail with `Component "data-table" failed to render` and React error #185, while the record's full page drew the same table. The table leaves out the columns that do not fit whole in its column, and re-reads that choice when it changes. The re-read measured the table still drawn for the previous choice, because the table adopts a new set of columns a render later. In the drawer's narrow details column that read changed its answer on every render: one column, then two, then one again. The read now waits until the table draws the columns it was handed, and the table's next draw reads again. A table wide enough for every column, as on the full page, is unchanged. +A record's related table drawn in the details of the record preview drawer (for example an opportunity's line items) could fail with `Component "data-table" failed to render` and React error #185, while the record's full page drew the same table. The table leaves out the columns that do not fit whole in its column, and re-reads that choice when it changes. The re-read measured the table still drawn for the previous choice, because the table adopts a new set of columns a render later. In the drawer's narrow details column that read changed its answer on every render: one column, then two, then one again. The read now skips the table while it still draws the columns it was handed before, and reads again when the table draws the new ones. A column the reader hid from the table's header menu does not stop the read, so a later narrowing still leaves columns out and shows the overflow cue. A table wide enough for every column, as on the full page, is unchanged.