From 143478a30a9ab04a047525ffec0ae3fbdcb285b4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:04:06 +0000 Subject: [PATCH 1/5] fix(console): Hide column in the column-header menu joins the list draft, as the view-settings eye does (#35955) Claude-Session: https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds Co-authored-by: Claude --- .../src/renderers/complex/data-table.tsx | 3 + ui/packages/plugin-grid/src/ObjectGrid.tsx | 15 +++ .../ObjectGrid.headerMenuHide-35955.test.tsx | 107 ++++++++++++++++ ui/packages/plugin-list/src/ListView.tsx | 17 +++ .../src/__tests__/ListView.harness.test.tsx | 120 ++++++++++++++++++ .../src/__tests__/zod-mirror-parity.test.ts | 12 +- ui/packages/types/src/data-display.ts | 13 ++ ui/packages/types/src/zod/data-display.zod.ts | 5 + 8 files changed, 290 insertions(+), 2 deletions(-) create mode 100644 ui/packages/plugin-grid/src/__tests__/ObjectGrid.headerMenuHide-35955.test.tsx diff --git a/ui/packages/components/src/renderers/complex/data-table.tsx b/ui/packages/components/src/renderers/complex/data-table.tsx index bdd4df1d66a..3452fbe3333 100644 --- a/ui/packages/components/src/renderers/complex/data-table.tsx +++ b/ui/packages/components/src/renderers/complex/data-table.tsx @@ -2670,6 +2670,9 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => { } setColumns(prev => prev.filter(c => c.accessorKey !== columnKey)); setContextMenu(null); + // objectstack#35955 — a host that keeps the columns shown owns the choice + // (the list holds it in its draft, as the hide-fields eye does). + schema.onColumnHide?.(columnKey); }; const handleSelectAll = (checked: boolean) => { diff --git a/ui/packages/plugin-grid/src/ObjectGrid.tsx b/ui/packages/plugin-grid/src/ObjectGrid.tsx index 1b6644db463..2804e460908 100644 --- a/ui/packages/plugin-grid/src/ObjectGrid.tsx +++ b/ui/packages/plugin-grid/src/ObjectGrid.tsx @@ -406,6 +406,17 @@ export interface ObjectGridComponentProps extends ObjectGridExternalPaginationPr * key reaches it. */ headerMenu?: boolean; + /** + * [objectstack#35955] Hears the column menu's "Hide column" with the + * column's field, as the HOST that keeps the columns shown asks for it (the + * list page holds the hidden fields in its draft, as its hide-fields eye + * does). The table hides the column either way. Absent ⇒ the hide lives in + * the table's own state alone, as before this prop existed. + * + * A RUNTIME prop, never authored metadata: the host decides it, and no node + * key reaches it. + */ + onColumnHide?: (field: string) => void; /** * [objectstack#36015] Opens a record that a lookup cell's chip names, in * place, as the HOST that owns the page does it (the list page opens it in @@ -851,6 +862,7 @@ export const ObjectGrid: React.FC = ({ rowOpensRecord, cellSelection: hostCellSelection, headerMenu: hostHeaderMenu, + onColumnHide: hostOnColumnHide, openReferencedRecord, onBulkDelete, onRowSelect, @@ -3774,6 +3786,9 @@ export const ObjectGrid: React.FC = ({ // on `DataTableSchema` and stays unwired, exactly as the RuntimeOnlyDeclared // ledger records it. Which of the two declared spellings survives is still an // open ruling and is deliberately NOT settled here. + // objectstack#35955 — the column menu's "Hide column", to the host that + // keeps the columns shown. + ...(hostOnColumnHide ? { onColumnHide: hostOnColumnHide } : {}), onColumnsReorder: (newColumns: any[]) => { const order = newColumns .map((c) => c?.accessorKey) diff --git a/ui/packages/plugin-grid/src/__tests__/ObjectGrid.headerMenuHide-35955.test.tsx b/ui/packages/plugin-grid/src/__tests__/ObjectGrid.headerMenuHide-35955.test.tsx new file mode 100644 index 00000000000..9dd97048a17 --- /dev/null +++ b/ui/packages/plugin-grid/src/__tests__/ObjectGrid.headerMenuHide-35955.test.tsx @@ -0,0 +1,107 @@ +/** + * ObjectUI + * Copyright (c) 2024-present ObjectStack Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +/** + * objectstack#35955 — through the real `ObjectGrid` and its `data-table`, the + * column menu's "Hide column" reaches the host that keeps the columns shown + * (`onColumnHide`, with the column's field), so the list page can hold it in + * the list's draft the way the hide-fields eye does. Before, the table only + * dropped the column from its own state: the column went, nothing above the + * table heard of it, and the list drew neither Discard nor Save. + * + * The CONTROL: with no `onColumnHide` the column still goes, so the hide is + * the table's own, as before. + */ +import { describe, it, expect, vi, beforeAll } from 'vitest'; +import { render, screen, waitFor, fireEvent, within } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import React from 'react'; + +import { ObjectGrid } from '../ObjectGrid'; +import { registerAllFields } from '@object-ui/fields'; +import { ActionProvider } from '@object-ui/react'; + +registerAllFields(); + +beforeAll(() => { + if (!Element.prototype.hasPointerCapture) { + Element.prototype.hasPointerCapture = vi.fn(() => false) as any; + } + if (!Element.prototype.scrollIntoView) { + Element.prototype.scrollIntoView = vi.fn() as any; + } +}); + +function makeDataSource() { + return { + find: vi.fn(async () => ({ + data: [{ id: '1', name: 'Row 0', stage: 'open', amount: 10 }], + total: 1, + })), + getObjectSchema: async (name: string) => ({ + name, + fields: { + id: { type: 'text' }, + name: { type: 'text', label: 'Name' }, + stage: { type: 'text', label: 'Stage' }, + amount: { type: 'number', label: 'Amount' }, + }, + }), + } as any; +} + +const headers = (container: HTMLElement) => + Array.from(container.querySelectorAll('thead th[data-column-key]')).map((th) => + th.getAttribute('data-column-key'), + ); + +function mount(onColumnHide?: (field: string) => void) { + return render( + + ({ field })), + } as any} + dataSource={makeDataSource()} + headerMenu + {...(onColumnHide ? { onColumnHide } : {})} + /> + , + ); +} + +async function hideFromHeaderMenu(container: HTMLElement, field: string) { + const th = container.querySelector(`thead th[data-column-key="${field}"]`)!; + fireEvent.click(th); + fireEvent.click(within(screen.getByTestId('column-context-menu')).getByText('Hide column')); +} + +describe('ObjectGrid — the column menu\'s Hide column reaches the host (objectstack#35955)', () => { + it('hands the host the hidden column\'s field, once, and the column goes', async () => { + const onColumnHide = vi.fn(); + const { container } = mount(onColumnHide); + await waitFor(() => expect(screen.getByText('Row 0')).toBeInTheDocument()); + expect(headers(container)).toEqual(expect.arrayContaining(['name', 'stage', 'amount'])); + + await hideFromHeaderMenu(container, 'stage'); + + expect(onColumnHide).toHaveBeenCalledTimes(1); + expect(onColumnHide).toHaveBeenCalledWith('stage'); + await waitFor(() => expect(headers(container)).not.toContain('stage')); + }); + + it('CONTROL: with no host handler the column still goes, in the table alone', async () => { + const { container } = mount(); + await waitFor(() => expect(screen.getByText('Row 0')).toBeInTheDocument()); + await hideFromHeaderMenu(container, 'stage'); + await waitFor(() => expect(headers(container)).not.toContain('stage')); + expect(headers(container)).toEqual(expect.arrayContaining(['name', 'amount'])); + }); +}); diff --git a/ui/packages/plugin-list/src/ListView.tsx b/ui/packages/plugin-list/src/ListView.tsx index 8f27117d26f..79bbc50ba51 100644 --- a/ui/packages/plugin-list/src/ListView.tsx +++ b/ui/packages/plugin-list/src/ListView.tsx @@ -6675,6 +6675,17 @@ export const ListView = React.forwardRef(({ updateOfferedHiddenFields(hidden); } }; + // objectstack#35955 — "Hide column" in the grid's column menu is the eye's + // own choice, made on one column: it goes through the same writer, so the + // host holds it in the list's draft (Discard brings the column back, Save + // keeps it hidden), and an added column leaves the reader's added fields as + // it does there. A key that names no column this list draws is the table's + // own business and is not reported. + const hideColumnFromMenu = (field: string) => { + if (offeredHiddenFields.has(field)) return; + if (!effectiveFields.some((column: unknown) => columnIdentity(column as any) === field)) return; + updateListedFields(new Set([...offeredHiddenFields, field])); + }; // Ticking an offered field adds it to the reader's list. A stale hidden // entry with the same name (a column the view has since dropped) is cleared // with it, or the added column would be drawn hidden. @@ -8494,6 +8505,12 @@ export const ListView = React.forwardRef(({ // menu instead of sorting on a click. ? { cellSelection: true, headerMenu: true } : {})} + {...(viewComponentSchema.type === 'object-grid' + // objectstack#35955 — the column menu's "Hide column" is the + // hide-fields eye's choice (`hideColumnFromMenu`), on the grid's + // host channel (a React prop, never a node key). + ? { onColumnHide: hideColumnFromMenu } + : {})} {...(ROW_OPENS_RECORD_VIEW_TYPES.has(viewComponentSchema.type) && rowOpensRecord !== undefined // objectstack#33317, objectstack#33548 — whether the host's row // click opens anything, on the view's host channel (a React diff --git a/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx index 78ebcefd5d3..bfa7ecd9da9 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx @@ -3591,3 +3591,123 @@ describe('ListView.groupPickerUnstored-32631', () => { }); }); }); + +// ── ListView.headerMenuHide-35955 ─────────────────────────────────────────────── + +/** + * objectstack#35955 — "Hide column" in the grid's column menu is the same + * choice as the eye in the hide-fields lists. The grid hands the column's + * field back (`onColumnHide`, pinned through the real grid and table in + * plugin-grid's `ObjectGrid.headerMenuHide-35955.test.tsx`); here: the list + * writes it through the eye's own writer, so its host hears it on + * `onHiddenFieldsChange` (the console holds it in the list's draft, which is + * what draws Discard and Save) and the grid is handed the columns without it. + * An added column leaves the reader's added fields, as unticking it does. A + * key naming no column the list draws reports nothing. + * + * plugin-grid is not a dependency of plugin-list, so a stub `object-grid` + * captures what ListView hands it. + */ +describe('ListView.headerMenuHide-35955', () => { + restoreAfterBlock(); + + const OBJECT = 'meeting_35955'; + const DEFINITION = { + name: OBJECT, + label: 'Meeting', + fields: { + name: { type: 'text', label: 'Name' }, + meeting_date: { type: 'date', label: 'Date' }, + location: { type: 'text', label: 'Location' }, + room: { type: 'text', label: 'Room' }, + }, + }; + + let gridProps: any = null; + let previousGrid: ReturnType; + beforeAll(() => { + previousGrid = ComponentRegistry.get('object-grid'); + ComponentRegistry.register('object-grid', (props: any) => { + gridProps = props; + return
; + }); + }); + afterAll(() => { + if (previousGrid) ComponentRegistry.register('object-grid', previousGrid); + }); + beforeEach(() => { gridProps = null; }); + + const drawn = () => (gridProps?.columns ?? []).map((c: any) => (typeof c === 'string' ? c : c.field)); + + function mount(opts: { hiddenFields?: string[]; added?: string[] } = {}) { + const onHiddenFieldsChange = vi.fn(); + const onAddedFieldsChange = vi.fn(); + const dataSource = { + find: vi.fn().mockResolvedValue({ data: [{ id: '1', name: 'A' }], total: 1 }), + findOne: vi.fn(), + create: vi.fn(), + update: vi.fn(), + delete: vi.fn(), + getObjectSchema: vi.fn(async () => structuredClone(DEFINITION)), + }; + const schema = { + type: 'list-view', + objectName: OBJECT, + viewType: 'grid', + columns: ['name', 'meeting_date', 'location', ...(opts.added ?? [])], + ...(opts.hiddenFields ? { hiddenFields: opts.hiddenFields } : {}), + } as unknown as ListViewSchema; + render( + + + , + ); + return { onHiddenFieldsChange, onAddedFieldsChange, dataSource }; + } + + async function hideFromMenu(field: string) { + await waitFor(() => expect(typeof gridProps?.onColumnHide).toBe('function')); + await act(async () => { gridProps.onColumnHide(field); }); + } + + it('hands the grid the column menu\'s hide, and reports it as the eye does: the hidden list, the column gone', async () => { + const { onHiddenFieldsChange } = mount(); + await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date', 'location'])); + await hideFromMenu('location'); + expect(onHiddenFieldsChange.mock.calls.at(-1)![0]).toEqual(['location']); + await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date'])); + }); + + it('adds to the columns already hidden, and hiding a hidden one again reports nothing', async () => { + const { onHiddenFieldsChange } = mount({ hiddenFields: ['meeting_date'] }); + await waitFor(() => expect(drawn()).toEqual(['name', 'location'])); + await hideFromMenu('location'); + expect(onHiddenFieldsChange).toHaveBeenCalledTimes(1); + expect([...onHiddenFieldsChange.mock.calls[0][0]].sort()).toEqual(['location', 'meeting_date']); + await hideFromMenu('meeting_date'); + expect(onHiddenFieldsChange).toHaveBeenCalledTimes(1); + }); + + it('a column the reader added leaves their added fields instead of being hidden', async () => { + const { onHiddenFieldsChange, onAddedFieldsChange } = mount({ added: ['room'] }); + await waitFor(() => expect(drawn()).toContain('room')); + await hideFromMenu('room'); + expect(onAddedFieldsChange.mock.calls.at(-1)![0]).toEqual([]); + expect(onHiddenFieldsChange).not.toHaveBeenCalled(); + }); + + it('a key that names no column the list draws reports nothing', async () => { + const { onHiddenFieldsChange, onAddedFieldsChange } = mount(); + await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date', 'location'])); + await hideFromMenu('_row_number'); + expect(onHiddenFieldsChange).not.toHaveBeenCalled(); + expect(onAddedFieldsChange).not.toHaveBeenCalled(); + expect(drawn()).toEqual(['name', 'meeting_date', 'location']); + }); +}); diff --git a/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts b/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts index f9656ad9527..300d91e3f1b 100644 --- a/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts +++ b/ui/packages/types/src/__tests__/zod-mirror-parity.test.ts @@ -154,7 +154,11 @@ * a delta to this number; count the registry. Nothing asserts it against a written * one, so this line is prose and can rot; the pin that cannot is the one * comparing the two halves to each other. - * - **51 entries** in `KnownDrift`, **91 keys** across them — 51 / 90 until + * - **51 entries** in `KnownDrift`, **92 keys** across them — 51 / 91 until + * objectstack#35955 declared `DataTableSchema.onColumnHide`, the host's + * handler for the column menu's "Hide column", as a runtime slot refused + * by name on the mirror, so it JOINED the same + * `data-display.zod.ts#DataTableSchema` entry. It was 51 / 90 until * objectstack#35678 declared `DataTableSchema.floatingBar`, the host-built * selection bar the table floats over its rows, as a runtime slot refused * by name on the mirror, so it JOINED the same @@ -2536,7 +2540,11 @@ interface KnownDrift { // objectstack#35678 — `floatingBar` is a RUNTIME SLOT in the same shape: // the host-built selection bar `data-table` floats over its rows // (`ObjectGrid` supplies it while rows are selected). - | 'floatingBar'; + | 'floatingBar' + // objectstack#35955 — `onColumnHide` is a RUNTIME SLOT in the objectui#6124 + // shape: `data-table` calls it with the column's key when the column menu's + // "Hide column" is picked; `ObjectGrid` forwards its host's handler. + | 'onColumnHide'; /** RUNTIME SLOT (objectui#7759 group E, the objectui#6124 shape): `data-table`, `ObjectGrid` and `VirtualGrid` call `col.cell(value, row)`. */ 'data-display.zod.ts#TableColumnSchema': 'cell'; /** diff --git a/ui/packages/types/src/data-display.ts b/ui/packages/types/src/data-display.ts index cd9cbdf1aa2..d13572f638c 100644 --- a/ui/packages/types/src/data-display.ts +++ b/ui/packages/types/src/data-display.ts @@ -1536,6 +1536,19 @@ export interface DataTableSchema extends BaseSchema { * (`schema.onColumnsReorder(newColumns)`). */ onColumnsReorder?: (columns: TableColumn[]) => void; + /** + * Column hide handler (objectstack#35955): called with the column's + * `accessorKey` when the reader picks "Hide column" in the column menu. The + * table hides the column in its own state either way; a host that keeps the + * columns shown (the list's hidden fields) hears the choice here and owns it + * from then on. Absent ⇒ the hide lives in the table's state alone. + * + * RUNTIME SLOT (the objectui#6124 shape) — a host-supplied function, NOT + * authorable metadata: JSON has no function value, so the zod twin refuses + * this key by name. Called by `renderers/complex/data-table.tsx`; supplied by + * `ObjectGrid` (`@object-ui/plugin-grid`) from its `onColumnHide` prop. + */ + onColumnHide?: (columnKey: string) => void; /** * Enable inline cell editing * When true, cells become editable on double-click or Enter key diff --git a/ui/packages/types/src/zod/data-display.zod.ts b/ui/packages/types/src/zod/data-display.zod.ts index a01f71ba796..d8f28045d84 100644 --- a/ui/packages/types/src/zod/data-display.zod.ts +++ b/ui/packages/types/src/zod/data-display.zod.ts @@ -496,6 +496,11 @@ export const DataTableSchema = BaseSchema.extend({ }).optional().describe('Per-record CEL predicates for the built-in row Delete item (objectui#2614)'), onSelectionChange: handlerKeyRefusal('onSelectionChange', 'runtime-slot', 'Selection change handler'), onColumnsReorder: handlerKeyRefusal('onColumnsReorder', 'runtime-slot', 'Column reorder handler'), + // RUNTIME SLOT (objectstack#35955): `data-table` calls `schema.onColumnHide` + // with the column's key when the column menu's "Hide column" is picked; its + // supplier is `ObjectGrid` (`@object-ui/plugin-grid`). A function is not + // JSON, so authored data is refused by name. + onColumnHide: handlerKeyRefusal('onColumnHide', 'runtime-slot', 'Column hide handler'), // ⭐ `75fca9669` — seven keys the REGISTERED `data-table` renderer reads off // the authored document while this arm declared none of them. `BaseSchema` is // `.passthrough()`, so an undeclared key is NOT refused: it stops being judged From 97323ea032a40f887765fbec0d800008a8fead10 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:05:49 +0000 Subject: [PATCH 2/5] test(plugin-list): keep the header-menu hide pin off the harness's last block Claude-Session: https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds Co-authored-by: Claude --- .../src/__tests__/ListView.harness.test.tsx | 240 +++++++++--------- 1 file changed, 120 insertions(+), 120 deletions(-) diff --git a/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx b/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx index bfa7ecd9da9..ab190b53f7c 100644 --- a/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx +++ b/ui/packages/plugin-list/src/__tests__/ListView.harness.test.tsx @@ -3416,6 +3416,126 @@ describe('ListView.setupChrome-12606', () => { }); }); +// ── ListView.headerMenuHide-35955 ─────────────────────────────────────────────── + +/** + * objectstack#35955 — "Hide column" in the grid's column menu is the same + * choice as the eye in the hide-fields lists. The grid hands the column's + * field back (`onColumnHide`, pinned through the real grid and table in + * plugin-grid's `ObjectGrid.headerMenuHide-35955.test.tsx`); here: the list + * writes it through the eye's own writer, so its host hears it on + * `onHiddenFieldsChange` (the console holds it in the list's draft, which is + * what draws Discard and Save) and the grid is handed the columns without it. + * An added column leaves the reader's added fields, as unticking it does. A + * key naming no column the list draws reports nothing. + * + * plugin-grid is not a dependency of plugin-list, so a stub `object-grid` + * captures what ListView hands it. + */ +describe('ListView.headerMenuHide-35955', () => { + restoreAfterBlock(); + + const OBJECT = 'meeting_35955'; + const DEFINITION = { + name: OBJECT, + label: 'Meeting', + fields: { + name: { type: 'text', label: 'Name' }, + meeting_date: { type: 'date', label: 'Date' }, + location: { type: 'text', label: 'Location' }, + room: { type: 'text', label: 'Room' }, + }, + }; + + let gridProps: any = null; + let previousGrid: ReturnType; + beforeAll(() => { + previousGrid = ComponentRegistry.get('object-grid'); + ComponentRegistry.register('object-grid', (props: any) => { + gridProps = props; + return
; + }); + }); + afterAll(() => { + if (previousGrid) ComponentRegistry.register('object-grid', previousGrid); + }); + beforeEach(() => { gridProps = null; }); + + const drawn = () => (gridProps?.columns ?? []).map((c: any) => (typeof c === 'string' ? c : c.field)); + + function mount(opts: { hiddenFields?: string[]; added?: string[] } = {}) { + const onHiddenFieldsChange = vi.fn(); + const onAddedFieldsChange = vi.fn(); + const dataSource = { + find: vi.fn().mockResolvedValue({ data: [{ id: '1', name: 'A' }], total: 1 }), + findOne: vi.fn(), + create: vi.fn(), + update: vi.fn(), + delete: vi.fn(), + getObjectSchema: vi.fn(async () => structuredClone(DEFINITION)), + }; + const schema = { + type: 'list-view', + objectName: OBJECT, + viewType: 'grid', + columns: ['name', 'meeting_date', 'location', ...(opts.added ?? [])], + ...(opts.hiddenFields ? { hiddenFields: opts.hiddenFields } : {}), + } as unknown as ListViewSchema; + render( + + + , + ); + return { onHiddenFieldsChange, onAddedFieldsChange, dataSource }; + } + + async function hideFromMenu(field: string) { + await waitFor(() => expect(typeof gridProps?.onColumnHide).toBe('function')); + await act(async () => { gridProps.onColumnHide(field); }); + } + + it('hands the grid the column menu\'s hide, and reports it as the eye does: the hidden list, the column gone', async () => { + const { onHiddenFieldsChange } = mount(); + await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date', 'location'])); + await hideFromMenu('location'); + expect(onHiddenFieldsChange.mock.calls.at(-1)![0]).toEqual(['location']); + await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date'])); + }); + + it('adds to the columns already hidden, and hiding a hidden one again reports nothing', async () => { + const { onHiddenFieldsChange } = mount({ hiddenFields: ['meeting_date'] }); + await waitFor(() => expect(drawn()).toEqual(['name', 'location'])); + await hideFromMenu('location'); + expect(onHiddenFieldsChange).toHaveBeenCalledTimes(1); + expect([...onHiddenFieldsChange.mock.calls[0][0]].sort()).toEqual(['location', 'meeting_date']); + await hideFromMenu('meeting_date'); + expect(onHiddenFieldsChange).toHaveBeenCalledTimes(1); + }); + + it('a column the reader added leaves their added fields instead of being hidden', async () => { + const { onHiddenFieldsChange, onAddedFieldsChange } = mount({ added: ['room'] }); + await waitFor(() => expect(drawn()).toContain('room')); + await hideFromMenu('room'); + expect(onAddedFieldsChange.mock.calls.at(-1)![0]).toEqual([]); + expect(onHiddenFieldsChange).not.toHaveBeenCalled(); + }); + + it('a key that names no column the list draws reports nothing', async () => { + const { onHiddenFieldsChange, onAddedFieldsChange } = mount(); + await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date', 'location'])); + await hideFromMenu('_row_number'); + expect(onHiddenFieldsChange).not.toHaveBeenCalled(); + expect(onAddedFieldsChange).not.toHaveBeenCalled(); + expect(drawn()).toEqual(['name', 'meeting_date', 'location']); + }); +}); + // ── ListView.groupPickerUnstored-32631 ────────────────────────────────────────── /** @@ -3591,123 +3711,3 @@ describe('ListView.groupPickerUnstored-32631', () => { }); }); }); - -// ── ListView.headerMenuHide-35955 ─────────────────────────────────────────────── - -/** - * objectstack#35955 — "Hide column" in the grid's column menu is the same - * choice as the eye in the hide-fields lists. The grid hands the column's - * field back (`onColumnHide`, pinned through the real grid and table in - * plugin-grid's `ObjectGrid.headerMenuHide-35955.test.tsx`); here: the list - * writes it through the eye's own writer, so its host hears it on - * `onHiddenFieldsChange` (the console holds it in the list's draft, which is - * what draws Discard and Save) and the grid is handed the columns without it. - * An added column leaves the reader's added fields, as unticking it does. A - * key naming no column the list draws reports nothing. - * - * plugin-grid is not a dependency of plugin-list, so a stub `object-grid` - * captures what ListView hands it. - */ -describe('ListView.headerMenuHide-35955', () => { - restoreAfterBlock(); - - const OBJECT = 'meeting_35955'; - const DEFINITION = { - name: OBJECT, - label: 'Meeting', - fields: { - name: { type: 'text', label: 'Name' }, - meeting_date: { type: 'date', label: 'Date' }, - location: { type: 'text', label: 'Location' }, - room: { type: 'text', label: 'Room' }, - }, - }; - - let gridProps: any = null; - let previousGrid: ReturnType; - beforeAll(() => { - previousGrid = ComponentRegistry.get('object-grid'); - ComponentRegistry.register('object-grid', (props: any) => { - gridProps = props; - return
; - }); - }); - afterAll(() => { - if (previousGrid) ComponentRegistry.register('object-grid', previousGrid); - }); - beforeEach(() => { gridProps = null; }); - - const drawn = () => (gridProps?.columns ?? []).map((c: any) => (typeof c === 'string' ? c : c.field)); - - function mount(opts: { hiddenFields?: string[]; added?: string[] } = {}) { - const onHiddenFieldsChange = vi.fn(); - const onAddedFieldsChange = vi.fn(); - const dataSource = { - find: vi.fn().mockResolvedValue({ data: [{ id: '1', name: 'A' }], total: 1 }), - findOne: vi.fn(), - create: vi.fn(), - update: vi.fn(), - delete: vi.fn(), - getObjectSchema: vi.fn(async () => structuredClone(DEFINITION)), - }; - const schema = { - type: 'list-view', - objectName: OBJECT, - viewType: 'grid', - columns: ['name', 'meeting_date', 'location', ...(opts.added ?? [])], - ...(opts.hiddenFields ? { hiddenFields: opts.hiddenFields } : {}), - } as unknown as ListViewSchema; - render( - - - , - ); - return { onHiddenFieldsChange, onAddedFieldsChange, dataSource }; - } - - async function hideFromMenu(field: string) { - await waitFor(() => expect(typeof gridProps?.onColumnHide).toBe('function')); - await act(async () => { gridProps.onColumnHide(field); }); - } - - it('hands the grid the column menu\'s hide, and reports it as the eye does: the hidden list, the column gone', async () => { - const { onHiddenFieldsChange } = mount(); - await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date', 'location'])); - await hideFromMenu('location'); - expect(onHiddenFieldsChange.mock.calls.at(-1)![0]).toEqual(['location']); - await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date'])); - }); - - it('adds to the columns already hidden, and hiding a hidden one again reports nothing', async () => { - const { onHiddenFieldsChange } = mount({ hiddenFields: ['meeting_date'] }); - await waitFor(() => expect(drawn()).toEqual(['name', 'location'])); - await hideFromMenu('location'); - expect(onHiddenFieldsChange).toHaveBeenCalledTimes(1); - expect([...onHiddenFieldsChange.mock.calls[0][0]].sort()).toEqual(['location', 'meeting_date']); - await hideFromMenu('meeting_date'); - expect(onHiddenFieldsChange).toHaveBeenCalledTimes(1); - }); - - it('a column the reader added leaves their added fields instead of being hidden', async () => { - const { onHiddenFieldsChange, onAddedFieldsChange } = mount({ added: ['room'] }); - await waitFor(() => expect(drawn()).toContain('room')); - await hideFromMenu('room'); - expect(onAddedFieldsChange.mock.calls.at(-1)![0]).toEqual([]); - expect(onHiddenFieldsChange).not.toHaveBeenCalled(); - }); - - it('a key that names no column the list draws reports nothing', async () => { - const { onHiddenFieldsChange, onAddedFieldsChange } = mount(); - await waitFor(() => expect(drawn()).toEqual(['name', 'meeting_date', 'location'])); - await hideFromMenu('_row_number'); - expect(onHiddenFieldsChange).not.toHaveBeenCalled(); - expect(onAddedFieldsChange).not.toHaveBeenCalled(); - expect(drawn()).toEqual(['name', 'meeting_date', 'location']); - }); -}); From 0df343620c243699ea18d3f47211858131523f57 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:06:57 +0000 Subject: [PATCH 3/5] chore(changeset): header-menu hide joins the list draft Claude-Session: https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds Co-authored-by: Claude --- .changeset/35955-header-menu-hide-draft.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .changeset/35955-header-menu-hide-draft.md diff --git a/.changeset/35955-header-menu-hide-draft.md b/.changeset/35955-header-menu-hide-draft.md new file mode 100644 index 00000000000..90d08004a01 --- /dev/null +++ b/.changeset/35955-header-menu-hide-draft.md @@ -0,0 +1,15 @@ +--- +'@object-ui/types': patch +'@object-ui/components': patch +'@object-ui/plugin-grid': patch +'@object-ui/plugin-list': patch +--- + +fix(console): Hide column in the column-header menu is a list draft, like the eye in View settings + +Clause-②: yes (widening) — one new optional runtime slot `DataTableSchema.onColumnHide(columnKey)` (refused by name on the zod mirror, like `onColumnsReorder`) and one new optional `ObjectGrid` prop `onColumnHide(field)`; nothing removed or renamed +Metadata-protocol: none + +On a Console object list, picking "Hide column" in a column header's menu hid the column inside the table only: nothing above the table heard of it, so the list drew neither Discard nor Save and only a reload brought the column back. The same choice made with the eye in View settings was already a draft. + +The table now reports the hidden column to its host (`DataTableSchema.onColumnHide`, supplied by `ObjectGrid` from its new `onColumnHide` prop), and `ListView` writes it through the same writer as the hide-fields eye: the host hears it on `onHiddenFieldsChange` (the Console holds it in the list's draft, so Discard brings the column back and Save keeps it hidden), and a column the reader added leaves their added fields, as unticking it does. A table with no host handler hides the column in its own state, as before. From 47950b64f8fd15f19a564edce7df510898ce08af Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 08:43:59 +0000 Subject: [PATCH 4/5] test(types): pin DataTableSchema.onColumnHide as declared, with its shape Claude-Session: https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds Co-authored-by: Claude --- .../src/__tests__/data-table-declared-keys-6882.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ui/packages/types/src/__tests__/data-table-declared-keys-6882.test.ts b/ui/packages/types/src/__tests__/data-table-declared-keys-6882.test.ts index eb2a02fefd7..3fc43a09c87 100644 --- a/ui/packages/types/src/__tests__/data-table-declared-keys-6882.test.ts +++ b/ui/packages/types/src/__tests__/data-table-declared-keys-6882.test.ts @@ -210,6 +210,13 @@ type _SummaryRowShapeWithoutLeadIsRefused = Expect>; type _FloatingBarShape = Expect['floatingBar'], React.ReactNode>>; +/** + * objectstack#35955 — the column menu's "Hide column" handler, `onColumnHide`: + * `data-table.tsx` calls it with the column's key; `ObjectGrid` supplies it. + */ +type _OnColumnHideIsDeclared = Expect>; +type _OnColumnHideShape = Expect['onColumnHide'], ((columnKey: string) => void) | undefined>>; + describe('objectui#6882 — DataTableSchema declares the two keys data-table reads', () => { /** * The runtime half exists only so the compile-time pins above have a file From da38b4814890b937986298543557d1215e367c26 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 22 Nov 2026 10:01:38 +0000 Subject: [PATCH 5/5] test(types): pin DataTableSchema.onColumnHide among the by-name runtime-slot refusals Claude-Session: https://claude.ai/code/session_01QsR2jUc3qp6bHKSWijbjds Co-authored-by: Claude --- .../handler-keys-json-refusal-6124.test.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ui/packages/types/src/__tests__/handler-keys-json-refusal-6124.test.ts b/ui/packages/types/src/__tests__/handler-keys-json-refusal-6124.test.ts index 34981fc21f6..7198ecf8c99 100644 --- a/ui/packages/types/src/__tests__/handler-keys-json-refusal-6124.test.ts +++ b/ui/packages/types/src/__tests__/handler-keys-json-refusal-6124.test.ts @@ -233,7 +233,7 @@ const objectOf = (mirror: z.ZodType, key: string): z.ZodObject => }; /** - * 60 keys whose function value REACHES a renderer at runtime — the TypeScript + * 61 keys whose function value REACHES a renderer at runtime — the TypeScript * interface keeps the function type (36 at the objectui#6124 census; 38 since * `ObjectDataTableSchema.onRowClick`, objectui#6576, and `AlertDialogSchema.onAction`, * objectui#7104, joined; 44 since objectui#7655 gave `chatbot-enhanced` and @@ -241,7 +241,8 @@ const objectOf = (mirror: z.ZodType, key: string): z.ZodObject => * registration forwards; 51 since objectui#7804's `DataTableSchema` slice * declared the seven keys that arm's renderer had been reading undeclared; * 60 since the same card's `objectql.ts` slice declared nine more across four - * arms in that one mirror file). + * arms in that one mirror file; 61 since objectstack#35955 declared + * `DataTableSchema.onColumnHide`, the column menu's "Hide column" handler). * ⛔ Do not add a delta to this figure — the pin that cannot rot is * `expect(RUNTIME_SLOT).toHaveLength(…)` below; count the constant. * Channel measured per key on this tree: @@ -293,6 +294,9 @@ const RUNTIME_SLOT: readonly Site[] = [ ['data-display.zod.ts', 'DataTableSchema', 'onRowDelete', DataTableZod], ['data-display.zod.ts', 'DataTableSchema', 'onSelectionChange', DataTableZod], ['data-display.zod.ts', 'DataTableSchema', 'onColumnsReorder', DataTableZod], + // objectstack#35955 — `data-table` calls `schema.onColumnHide(columnKey)` when + // the column menu's "Hide column" is picked; `ObjectGrid` supplies it. + ['data-display.zod.ts', 'DataTableSchema', 'onColumnHide', DataTableZod], // ⭐ objectui#7804 — the `DataTableSchema` slice, seven keys the REGISTERED // `data-table` renderer read off the authored document while this arm declared // none of them, so `BaseSchema.passthrough()` ACCEPTED and KEPT an authored @@ -568,7 +572,7 @@ describe('census: no on* key in the eight mirrors is declared z.function() (obje expect([...spelled.matchAll(NON_ON_FUNCTION)].map((m) => m[1])).toEqual(['cell']); }); - it('82 sites are ledgered, 60 runtime slots + 22 retired, with no key filed twice', () => { + it('83 sites are ledgered, 61 runtime slots + 22 retired, with no key filed twice', () => { // 58 from objectui#6124; the 59th is `ObjectDataTableSchema.onRowClick`, // minted with its arm by objectui#6576 / #6914; the 60th is // `AlertDialogSchema.onAction`, declared by objectui#7104 for a key the @@ -618,10 +622,14 @@ describe('census: no on* key in the eight mirrors is declared z.function() (obje // `ObjectKanbanSchema.onQuickAdd` from the runtime-slot half to the retired // half. A move between halves holds `ALL_SITES` at the same size, so the two // half lengths are the readings that see it, and both are pinned here. - expect(RUNTIME_SLOT).toHaveLength(60); + // + // ⭐ 60 + 22 → 61 + 22: objectstack#35955 declared + // `DataTableSchema.onColumnHide`, a runtime slot the `data-table` renderer + // calls from its column menu. + expect(RUNTIME_SLOT).toHaveLength(61); expect(RETIRED).toHaveLength(22); const ids = ALL_SITES.map(([file, schema, key]) => `${file}#${schema}.${key}`); - expect(new Set(ids).size).toBe(82); + expect(new Set(ids).size).toBe(83); }); it.each(ALL_SITES)('%s %s.%s is DECLARED on the mirror shape, with the objectui#6124 guidance as its description', (_file, _schema, key, mirror) => { @@ -784,6 +792,8 @@ export type assertionRuntimeSlotsKeepTheirFunctionType = [ Expect>, Expect>, Expect>, + // objectstack#35955 — the column menu's "Hide column" handler. + Expect>, // objectui#7804 — the `DataTableSchema` slice. Each TS twin stays callable // because the function value REACHES the renderer; the mirror refuses by name. Expect>,