From 801f82236b8314316a9a82b4306f19415e80c624 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 08:00:31 +0000 Subject: [PATCH 1/6] fix(plugin-detail): the Overview draws the record's own field groups before its master-detail tables Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ --- ...DefaultPageSchema.bodyTables-27055.test.ts | 161 ++++++++++++++++-- .../src/synth/buildDefaultPageSchema.ts | 71 ++++++-- 2 files changed, 208 insertions(+), 24 deletions(-) diff --git a/ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts b/ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts index b6369627550..48210cae761 100644 --- a/ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts +++ b/ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts @@ -13,9 +13,11 @@ * * A related list that is the record's own body (`isBody`, else * `relatedList: 'primary'`) is a table section of the Details tab, placed - * BEFORE the field sections (objectstack#35597, 「关键字段下面」: under the header - * strip, above the field groups; objectstack#27069 placed it after the FIRST - * section); several stack in the order given; the sections follow. Every other + * AFTER the field sections the page draws open (objectstack#35742: the + * record's own fields first, then its master-detail tables; objectstack#35597 + * placed it before every section, objectstack#27069 after the FIRST one); + * several stack in the order given. The sections drawn closed that trail the + * last open one follow the tables. Every other * list is a tab of its own (objectstack#35595, which retired the one `Related` * tab). A field group whose `relatedList` names a body table's * relationship places that table at the group's position instead @@ -52,15 +54,15 @@ const shape = (nodes: any[]) => : `${n.type === 'record:related_list' ? 'table' : n.type}(${n.properties.objectName})`, ); -describe('body tables sit in the Details tab before the field sections (objectstack#27055, objectstack#35597)', () => { +describe('body tables sit in the Details tab after the field sections (objectstack#27055, objectstack#35742)', () => { it('splits the details around the body tables; each side list takes a tab of its own (objectstack#35595)', () => { const tabs = buildDefaultTabs(quoteDef, { sections: SECTIONS, related: [LINES, TASKS, SCHEDULE] }); // 动态 is last for every object (objectstack#34590). expect(items(tabs).map((i: any) => i.value)).toEqual(['details', 'related:task.quote', 'timeline']); expect(shape(items(tabs)[0].children)).toEqual([ + 'details(Basic,Terms,Notes)', 'table(quote_line_item)', 'table(quote_schedule)', - 'details(Basic,Terms,Notes)', ]); expect(tabOf(tabs, 'related:task.quote').children.map((n: any) => n.properties.objectName)).toEqual(['task']); }); @@ -82,9 +84,9 @@ describe('body tables sit in the Details tab before the field sections (objectst expect(items(asSide)[1].value).toBe('related:task.quote'); }); - it('with one section the tables lead it', () => { + it('with one section the tables follow it', () => { const tabs = buildDefaultTabs(quoteDef, { sections: SECTIONS.slice(0, 1), related: [LINES] }); - expect(shape(items(tabs)[0].children)).toEqual(['table(quote_line_item)', 'details(Basic)']); + expect(shape(items(tabs)[0].children)).toEqual(['details(Basic)', 'table(quote_line_item)']); }); it('with no section the details node (the highlight fields) leads and the tables follow it', () => { @@ -110,7 +112,7 @@ describe('the page knows its body tables', () => { it('the laid-out page draws them in the details column, side lists as the right column\'s panels', () => { const columns = buildDefaultPageColumns(page)!; - expect(shape(columns.details)).toEqual(['table(quote_line_item)', 'details(Basic,Terms,Notes)']); + expect(shape(columns.details)).toEqual(['details(Basic,Terms,Notes)', 'table(quote_line_item)']); expect(columns.related.map((n: any) => n.properties.objectName)).toEqual(['task']); }); }); @@ -128,12 +130,12 @@ describe('a field group places a body table at its position (objectstack#27069, }); const detailsOf = (def: any, related: any[]) => shape(items(buildDefaultTabs(def, { related }))[0].children); - it('the table named by a group (child object name) sits at that group; the others keep "before the sections"', () => { + it('the table named by a group (child object name) sits at that group; the others keep "after the sections"', () => { expect(detailsOf(placed('quote_line_item'), [LINES, SCHEDULE])).toEqual([ - 'table(quote_schedule)', 'details(basic,terms)', 'table(quote_line_item)', 'details(notes)', + 'table(quote_schedule)', ]); }); @@ -144,8 +146,8 @@ describe('a field group places a body table at its position (objectstack#27069, 'details(notes)', ]); expect(detailsOf(placed('quote_line_item.other_fk'), [LINES])).toEqual([ - 'table(quote_line_item)', 'details(basic,terms,notes)', + 'table(quote_line_item)', ]); }); @@ -167,7 +169,7 @@ describe('a field group places a body table at its position (objectstack#27069, // The spec refuses this group (`isBodyTableRelationship`, ruling B on // objectstack#27055); the renderer never second-guesses body-ness either. const tabs = buildDefaultTabs(placed('task'), { related: [LINES, TASKS] }); - expect(shape(items(tabs)[0].children)).toEqual(['table(quote_line_item)', 'details(basic,terms,notes)']); + expect(shape(items(tabs)[0].children)).toEqual(['details(basic,terms,notes)', 'table(quote_line_item)']); expect(tabOf(tabs, 'related:task.quote').children.map((n: any) => n.properties.objectName)).toEqual(['task']); }); @@ -183,3 +185,138 @@ describe('a field group places a body table at its position (objectstack#27069, ]); }); }); + +describe("the record's own fields lead the Overview, its master-detail tables follow (objectstack#35742)", () => { + // A meeting: no stage field, no key fields, one master-detail child. + const meetingDef = { + name: 'meeting', + fields: { + subject: { type: 'text', label: 'Subject' }, + owner: { type: 'text', label: 'Owner', group: 'basic' }, + meeting_date: { type: 'date', label: 'Date', group: 'basic' }, + location: { type: 'text', label: 'Location', group: 'basic' }, + }, + fieldGroups: [{ key: 'basic', label: 'Basic' }], + }; + const TODOS = { objectName: 'meeting_todo', relationshipField: 'meeting', title: 'To-dos', isBody: true }; + const columnsOf = (def: any, options: any) => buildDefaultPageColumns(buildDefaultPageSchema(def, options))!; + const stripShape = (nodes: any[]) => nodes.map((n) => n.type); + + it('an object with no stage bar and no key fields draws its field groups first, the body table under them', () => { + const columns = columnsOf(meetingDef, { related: [TODOS] }); + expect(stripShape(columns.strip)).toEqual([]); + expect(shape(columns.details)).toEqual(['details(basic)', 'table(meeting_todo)']); + }); + + it('with a key-fields strip the order is strip, then the field groups, then the body table', () => { + const columns = columnsOf({ ...meetingDef, highlightFields: ['owner', 'meeting_date'] }, { related: [TODOS] }); + expect(stripShape(columns.strip)).toEqual(['record:highlights']); + expect(shape(columns.details)).toEqual(['details(basic)', 'table(meeting_todo)']); + }); + + it('with a stage bar and key fields the order is the strip (key fields, stage), the field groups, the body table', () => { + const staged = { + ...meetingDef, + highlightFields: ['owner'], + fields: { + ...meetingDef.fields, + status: { + type: 'select', + label: 'Status', + group: 'basic', + options: [{ value: 'planned', label: 'Planned' }, { value: 'held', label: 'Held' }], + }, + }, + }; + const columns = columnsOf(staged, { statusField: 'status', related: [TODOS] }); + expect(stripShape(columns.strip)).toEqual(['record:highlights', 'record:path']); + expect(shape(columns.details)).toEqual(['details(basic)', 'table(meeting_todo)']); + }); + + describe('a section drawn closed that trails the open ones follows the tables (common fields first)', () => { + const grouped = (collapses: Record) => ({ + name: 'quote', + fields: { + name: { type: 'text', label: 'Name', group: 'basic' }, + terms: { type: 'textarea', label: 'Terms', group: 'terms' }, + notes: { type: 'textarea', label: 'Notes', group: 'notes' }, + }, + fieldGroups: ['basic', 'terms', 'notes'].map((key) => + collapses[key] ? { key, label: key, collapse: collapses[key] } : { key, label: key }), + }); + + it('a trailing `collapsed` group (the `{ group }` reference form) follows the tables', () => { + expect(shape(items(buildDefaultTabs(grouped({ notes: 'collapsed' }), { related: [LINES] }))[0].children)).toEqual([ + 'details(basic,terms)', + 'table(quote_line_item)', + 'details(notes)', + ]); + }); + + it('a closed group between two open ones keeps its declared place before the tables', () => { + expect(shape(items(buildDefaultTabs(grouped({ terms: 'collapsed' }), { related: [LINES] }))[0].children)).toEqual([ + 'details(basic,terms,notes)', + 'table(quote_line_item)', + ]); + }); + + it('a `collapsible` group that opens expanded is a common one: it stays before the tables', () => { + expect(shape(items(buildDefaultTabs(grouped({ notes: 'collapsible' }), { related: [LINES] }))[0].children)).toEqual([ + 'details(basic,terms,notes)', + 'table(quote_line_item)', + ]); + }); + + it('with every section closed the tables follow them all: the record still leads', () => { + const allClosed = grouped({ basic: 'collapsed', terms: 'collapsed', notes: 'collapsed' }); + expect(shape(items(buildDefaultTabs(allClosed, { related: [LINES] }))[0].children)).toEqual([ + 'details(basic,terms,notes)', + 'table(quote_line_item)', + ]); + }); + + it('the enumerated form the host passes: `collapsible` + `defaultCollapsed` trails, an open "More details" leads', () => { + const closedMore = [ + { label: 'Basic', fields: ['name'] }, + { label: 'More details', collapsible: true, defaultCollapsed: true, fields: ['terms', 'notes'] }, + ]; + expect(shape(items(buildDefaultTabs(quoteDef, { sections: closedMore, related: [LINES] }))[0].children)).toEqual([ + 'details(Basic)', + 'table(quote_line_item)', + 'details(More details)', + ]); + // The host's "More details" (`deriveRecordDetailSections`) opens + // expanded, so it is drawn open and stays before the tables. + const openMore = [closedMore[0], { ...closedMore[1], defaultCollapsed: false }]; + expect(shape(items(buildDefaultTabs(quoteDef, { sections: openMore, related: [LINES] }))[0].children)).toEqual([ + 'details(Basic,More details)', + 'table(quote_line_item)', + ]); + }); + + it('a group-placed table keeps its group position ahead of the trailing closed group', () => { + const def = { + ...grouped({ notes: 'collapsed' }), + fieldGroups: [ + { key: 'basic', label: 'basic' }, + { key: 'lines', label: 'Lines', relatedList: 'quote_line_item' }, + { key: 'terms', label: 'terms' }, + { key: 'notes', label: 'notes', collapse: 'collapsed' }, + ], + }; + expect(shape(items(buildDefaultTabs(def, { related: [LINES, SCHEDULE] }))[0].children)).toEqual([ + 'details(basic)', + 'table(quote_line_item)', + 'details(terms)', + 'table(quote_schedule)', + 'details(notes)', + ]); + }); + }); + + it('CONTROL: an object with no body table draws one details node, and a side list never joins the Overview', () => { + const columns = columnsOf(meetingDef, { related: [{ ...TODOS, isBody: false }] }); + expect(shape(columns.details)).toEqual(['details(basic)']); + expect(columns.related.map((n: any) => n.properties.objectName)).toEqual(['meeting_todo']); + }); +}); diff --git a/ui/packages/plugin-detail/src/synth/buildDefaultPageSchema.ts b/ui/packages/plugin-detail/src/synth/buildDefaultPageSchema.ts index baa590717aa..a0218d674d3 100644 --- a/ui/packages/plugin-detail/src/synth/buildDefaultPageSchema.ts +++ b/ui/packages/plugin-detail/src/synth/buildDefaultPageSchema.ts @@ -797,6 +797,33 @@ export function buildDefaultDetails( }); } +/** + * Whether the record page draws a Details section CLOSED when it opens + * (objectstack#35742): an enumerated section that is `collapsible` and + * `defaultCollapsed`, or a `{ group }` reference whose group declares the + * `collapsed` collapse. A reference inherits its presentation from the group + * — the spec refuses `collapsible` / `defaultCollapsed` beside `group` — so + * it is read the way `record:details` resolves it, through + * {@link deriveFieldGroupDetailEntries}. A reference naming no declared group + * draws nothing and counts as open, which leaves the tables where they are. + */ +function sectionDrawnClosed(def: ObjectDefLike | undefined): (section: Record) => boolean { + let groups: Map> | null = null; + return (section) => { + if (typeof section?.group !== 'string') { + return section?.collapsible === true && section?.defaultCollapsed === true; + } + if (!groups) { + groups = new Map(); + for (const entry of deriveFieldGroupDetailEntries(def) ?? []) { + if (typeof entry.key === 'string') groups.set(entry.key, entry.section); + } + } + const resolved = groups.get(section.group); + return resolved?.collapsible === true && resolved?.defaultCollapsed === true; + }; +} + /** Rows on the first page of a body table (objectstack#27055, Target 8). */ export const BODY_TABLE_PAGE_SIZE = 10; @@ -814,12 +841,22 @@ export const BODY_TABLE_PAGE_SIZE = 10; * lists in `bodies` are placed, and a side card is never among them (objectstack#27478: * the spec refuses a group naming a side card or a hidden list, by the same * `isBodyTableRelationship` the host computes `isBody` with); - * - every other body table goes BEFORE the field sections (objectstack#35597, - * the maintainer's 「关键字段下面」: under the header strip's stage bar and key - * fields, above the field groups), stacked in the order given — the - * parent's `relatedLists`, then the derived order. With no section at all + * - every other body table goes AFTER the field sections the record page + * draws open (objectstack#35742: the record's own fields first, then its + * master-detail tables — 「主记录的字段分组 → 主从子表」; the header strip's + * stage bar and key fields sit above both, objectstack#35597's + * 「关键字段下面」), stacked in the order given — the parent's + * `relatedLists`, then the derived order. The sections drawn CLOSED that + * trail the last open one (a group whose collapse is `collapsed`, an + * enumerated section that is `collapsible` and `defaultCollapsed`) follow + * the tables: common fields before the tables, the fields an author tucked + * away after them ({@link sectionDrawnClosed}). The declared order of the + * sections is never changed — a closed section between two open ones stays + * between them — and when no section is drawn open the tables follow every + * section, so the record's own fields always lead. With no section at all * the details node leads (it draws the object's highlight fields) and the - * tables follow it. (objectstack#27069 drew them after the FIRST section.) + * tables follow it. (objectstack#27069 drew them after the FIRST section, + * objectstack#35597 before every section.) * * The details node is split around the tables: each run of consecutive * sections is one `record:details`. A section names its group by `group` (the @@ -864,10 +901,18 @@ export function bodyTablePlacement( return index ?? Number.POSITIVE_INFINITY; }; - if (placed.length === 0 && resolved.length <= 1) { - return resolved.length === 0 - ? [buildDefaultDetails(def, sections, hideFields), ...bodies] - : [...bodies, buildDefaultDetails(def, sections, hideFields)]; + // objectstack#35742 — the unplaced tables follow the last section drawn + // open; every section after it is drawn closed and follows the tables. No + // open section: the tables follow every section. + const closed = sectionDrawnClosed(def); + let lastOpen = -1; + resolved.forEach((section, index) => { + if (!closed(section)) lastOpen = index; + }); + const tablesAt = lastOpen === -1 ? resolved.length : lastOpen + 1; + + if (placed.length === 0 && tablesAt === resolved.length) { + return [buildDefaultDetails(def, sections, hideFields), ...bodies]; } // Lay the sections and the tables out in one sequence, then fold each run @@ -878,11 +923,12 @@ export function bodyTablePlacement( const flushPlacedBefore = (index: number) => { while (next < placed.length && placed[next].at < index) slots.push({ table: placed[next++].node }); }; - for (const node of unplaced) slots.push({ table: node }); - resolved.forEach((section) => { + resolved.forEach((section, index) => { flushPlacedBefore(sectionGroupIndex(section)); + if (index === tablesAt) for (const node of unplaced) slots.push({ table: node }); slots.push({ section }); }); + if (tablesAt === resolved.length) for (const node of unplaced) slots.push({ table: node }); while (next < placed.length) slots.push({ table: placed[next++].node }); const out: any[] = []; @@ -974,7 +1020,8 @@ function synthTabs( ...(rel.filter ? { filter: rel.filter } : {}), }); // objectstack#27055, Target 8 — a list that is the record's own body - // (`isBody`, else `isPrimary`) is a table section of the Details tab; every + // (`isBody`, else `isPrimary`) is a table section of the Details tab, after + // the record's own open field sections (objectstack#35742); every // other list is a tab of its own (objectstack#35595). Body tables keep the // order the host passed (the object's `relatedLists`, then the derived // order — objectstack#27069), unless a field group places one From fb347dc1468d8fb2e86b3d404b7a4228028a2496 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 08:09:36 +0000 Subject: [PATCH 2/6] test(plugin-detail): meeting fixture keeps its title in its one group Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ --- .../__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts b/ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts index 48210cae761..cd71bfe18c6 100644 --- a/ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts +++ b/ui/packages/plugin-detail/src/synth/__tests__/buildDefaultPageSchema.bodyTables-27055.test.ts @@ -191,7 +191,7 @@ describe("the record's own fields lead the Overview, its master-detail tables fo const meetingDef = { name: 'meeting', fields: { - subject: { type: 'text', label: 'Subject' }, + subject: { type: 'text', label: 'Subject', group: 'basic' }, owner: { type: 'text', label: 'Owner', group: 'basic' }, meeting_date: { type: 'date', label: 'Date', group: 'basic' }, location: { type: 'text', label: 'Location', group: 'basic' }, From a5c5f36375f87d009c560d133f014952d824043e Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 08:12:38 +0000 Subject: [PATCH 3/6] fix(plugin-detail): a body table draws the list's dense rows and only the columns that fit whole Co-authored-by: Claude Claude-Session: https://claude.ai/code/session_01Utp6CZrgaiMgTJCnswR6jQ --- ui/packages/plugin-detail/src/RelatedList.tsx | 102 +++++++++++++++-- .../RelatedList.bodyTable-27055.test.tsx | 108 ++++++++++++++---- 2 files changed, 183 insertions(+), 27 deletions(-) diff --git a/ui/packages/plugin-detail/src/RelatedList.tsx b/ui/packages/plugin-detail/src/RelatedList.tsx index 3b0bad16406..3de50553cd9 100644 --- a/ui/packages/plugin-detail/src/RelatedList.tsx +++ b/ui/packages/plugin-detail/src/RelatedList.tsx @@ -1010,6 +1010,53 @@ const BodyTableTotalsLine: React.FC<{ totals: readonly BodyTableTotal[] }> = ({ ); }; +/** + * A body table's density (objectstack#35742): the list's dense rows — a 32px + * cell over the row's 1px line, 33px a row — under a 32px header at 13px, the + * measures `object-grid` draws a list's `compact` rows with + * (objectstack#35548). On the table's root, so it reaches every header and + * body cell, the row-actions cell included, over the table primitive's + * roomier defaults. + */ +export const BODY_TABLE_DENSITY = [ + '[&_thead_th]:h-8 [&_thead_th]:px-3 [&_thead_th]:py-0 [&_thead_th]:text-[13px]', + '[&_tbody_td]:h-8 [&_tbody_td]:px-3 [&_tbody_td]:py-0 [&_tbody_td]:text-[13px] [&_tbody_td]:leading-tight', +].join(' '); + +/** + * The width a body table's drawn column asks for: the inline width the table + * gives its header cell (a user's resize, the declared width or the estimate + * from what its cells draw), which does not grow when the table stretches + * its columns to fill the row; else the drawn width. + */ +function bodyTableColumnWidth(th: HTMLElement): number { + const declared = th.style.minWidth; + if (/^\d+(\.\d+)?(px)?$/.test(declared)) return parseFloat(declared); + return th.getBoundingClientRect().width; +} + +/** + * How many of a body table's columns, in their priority order, fit whole in + * `available` px (objectstack#35742): the leading run whose widths sum to no + * more than it, never fewer than one. `null` when every column fits, or when + * a column's width is not known yet (it has not been drawn), so the table + * draws them all and is measured again. + */ +export function bodyTableColumnsThatFit( + keys: readonly string[], + widths: ReadonlyMap, + available: number, +): number | null { + let used = 0; + for (let index = 0; index < keys.length; index += 1) { + const width = widths.get(keys[index]); + if (width === undefined) return null; + used += width; + if (used > available) return Math.max(1, index); + } + return null; +} + /** The add config of {@link RelatedListProps.add}, as `derivedAddOf` derives one. */ type RelatedListAdd = NonNullable; @@ -3266,6 +3313,25 @@ export const RelatedList: React.FC = ({ // table's scroll box by the effect below the empty answer. const bodyTableHostRef = React.useRef(null); const [bodyTableOverflows, setBodyTableOverflows] = React.useState(false); + // objectstack#35742 — never a half-cut column: a body table draws the + // leading run of its columns, in their priority order, that fits whole in + // its column (`bodyTableColumnsThatFit`); the rest wait behind ⤢ 「全部列」. + // `null` draws every column. The width each column asks for is kept by its + // 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()); + const bodyTableColumnKeysKey = React.useMemo( + () => JSON.stringify((tableColumns ?? []).map((col: any) => String(col?.accessorKey ?? ''))), + [tableColumns], + ); + // A different column set is measured afresh, every column drawn. + React.useLayoutEffect(() => { + bodyTableColumnWidths.current.clear(); + setBodyTableColumnCap(null); + }, [bodyTableColumnKeysKey]); + const bodyTableColumnsOmitted = bodyTable && bodyTableColumnCap !== null; + // ⤢ in words, and the overflow cue: the table scrolls, or leaves columns out. + const bodyTableNarrow = bodyTableOverflows || bodyTableColumnsOmitted; // The row click hands the host the rows on show beside the clicked one // (objectstack#26679), so its drawer can step through them. @@ -3391,7 +3457,11 @@ export const RelatedList: React.FC = ({ return { type: 'data-table', data: paginatedData, - columns: compact ? tableColumns.slice(0, 1) : tableColumns, + columns: compact + ? tableColumns.slice(0, 1) + : bodyTableColumnsOmitted ? tableColumns.slice(0, bodyTableColumnCap!) : tableColumns, + // The list's dense rows and header (objectstack#35742). + ...(bodyTable ? { className: BODY_TABLE_DENSITY } : {}), // A body table wider than its column keeps its first column, the // row's identity, in view while it scrolls (objectstack#29945). ...(bodyTable && bodyTableOverflows ? { frozenColumns: 1 } : {}), @@ -3433,7 +3503,7 @@ export const RelatedList: React.FC = ({ default: return { type: 'div', children: 'No view configured' }; } - }, [type, paginatedData, tableColumns, effectiveColumns, schema, effectivePageSize, hasRowActions, hasCustomRowActions, rowActions, onRowAction, onRowEdit, onRowDelete, handleDeleteRow, handleRowClick, isMobile, compact, enlargedFace, api, objectSchema, activeSort, handleTableSort, bodyTable, bodyTableOverflows, bodySummaryRow, ownRelationshipId, storedListPreference?.columnState]); + }, [type, paginatedData, tableColumns, effectiveColumns, schema, effectivePageSize, hasRowActions, hasCustomRowActions, rowActions, onRowAction, onRowEdit, onRowDelete, handleDeleteRow, handleRowClick, isMobile, compact, enlargedFace, api, objectSchema, activeSort, handleTableSort, bodyTable, bodyTableOverflows, bodyTableColumnsOmitted, bodyTableColumnCap, bodySummaryRow, ownRelationshipId, storedListPreference?.columnState]); const enlargedGrid = enlargedFace && !schema && (type === 'grid' || type === 'table'); @@ -3569,8 +3639,24 @@ export const RelatedList: React.FC = ({ let resizes: ResizeObserver | null = null; let mounts: MutationObserver | null = null; const findBox = () => host.querySelector('[data-table-scroll-box]'); + const keys = readColumnKeys(bodyTableColumnKeysKey); const watch = (box: HTMLElement) => { - const read = () => setBodyTableOverflows(box.scrollWidth - box.clientWidth > 1); + const read = () => { + // 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. + let besideColumns = 0; + for (const th of Array.from(box.querySelectorAll('thead th'))) { + const key = th.getAttribute('data-column-key'); + if (key === null) besideColumns += th.getBoundingClientRect().width; + else bodyTableColumnWidths.current.set(key, bodyTableColumnWidth(th)); + } + // A box with no width has not been laid out: it leaves nothing out. + setBodyTableColumnCap(box.clientWidth > 0 + ? bodyTableColumnsThatFit(keys, bodyTableColumnWidths.current, box.clientWidth - besideColumns) + : null); + setBodyTableOverflows(box.scrollWidth - box.clientWidth > 1); + }; read(); if (typeof ResizeObserver === 'undefined') return; resizes = new ResizeObserver(read); @@ -3597,7 +3683,7 @@ export const RelatedList: React.FC = ({ mounts?.disconnect(); resizes?.disconnect(); }; - }, [bodyTableDrawn, isMobile]); + }, [bodyTableDrawn, isMobile, bodyTableColumnKeysKey]); // When the consumer explicitly enables `filterable`, always render the // filter input — they're opting in. (data-table's own auto-search is // suppressed via the viewSchema below to avoid a duplicate input.) @@ -4105,9 +4191,10 @@ export const RelatedList: React.FC = ({ {add.label || t('detail.add', { defaultValue: 'Add' })} )} - {bodyTable && enlargeRelated && ownRelationshipId && (bodyTableOverflows ? ( + {bodyTable && enlargeRelated && ownRelationshipId && (bodyTableNarrow ? ( // A table wider than its column offers ⤢ in words: the enlarged - // tab is where every column fits (objectstack#29945). + // tab is where every column fits (objectstack#29945), the ones + // the table left out included (objectstack#35742).