From 22fb95d04b6a529c0791168ea48d0c26aa335808 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Nov 2026 01:27:58 +0000 Subject: [PATCH 1/2] wip(ui): rich-text cell docs follow select-first; onBatchSave own remedy; test leftovers Claude-Session: https://claude.ai/code/session_01L9qibxEbSk19qJRPHrm3v9 Co-authored-by: Claude --- .../data-table-autosave-35685.test.tsx | 10 ++-- .../data-table-select-first-35684.test.tsx | 40 +++++++++++++-- .../src/renderers/complex/data-table.tsx | 33 +++++------- .../complex/dataTableBindDiagnostic.ts | 6 +-- ui/packages/fields/README.md | 9 ++-- ui/packages/fields/src/FieldEditWidget.tsx | 8 ++- .../src/affordanceGrantMap-12082.test.tsx | 5 +- .../inlineEditPermissionGate.test.tsx | 24 --------- .../handler-keys-json-refusal-6124.test.ts | 51 +++++++++++++++++-- ui/packages/types/src/zod/data-display.zod.ts | 15 +++++- ui/packages/types/src/zod/tombstone.zod.ts | 14 ++++- 11 files changed, 139 insertions(+), 76 deletions(-) diff --git a/ui/packages/components/src/__tests__/data-table-autosave-35685.test.tsx b/ui/packages/components/src/__tests__/data-table-autosave-35685.test.tsx index 5aaf9b659b3..d32c463977d 100644 --- a/ui/packages/components/src/__tests__/data-table-autosave-35685.test.tsx +++ b/ui/packages/components/src/__tests__/data-table-autosave-35685.test.tsx @@ -8,7 +8,7 @@ /** * `data-table`'s per-cell save in the select-first model (objectstack#35685), - * behind the `GridCellSelection` a host mounts. + * behind the `GridCellSelectionProvider` a host mounts. * * 1. A committed cell sends its record's update at once: one call, that * cell only; no save bar, no row Save/Cancel column, no amber row; the @@ -115,7 +115,7 @@ function deferredSave() { } describe('data-table autosave — a committed cell saves at once (objectstack#35685)', () => { - it('sends one update with that cell only, draws no save bar, no edit column and no amber row', async () => { + it('sends one update with that cell only, draws no save bar, no row Save button and no amber row', async () => { const { onRowSave, calls } = deferredSave(); const t = renderTable(onRowSave); t.typeAndEnter(0, 0, 'Alpha 2'); @@ -127,7 +127,6 @@ describe('data-table autosave — a committed cell saves at once (objectstack#35 expect(screen.queryByText(/Save All/)).toBeNull(); expect(screen.queryByText(/row modified/)).toBeNull(); expect(t.container.querySelector('button[title="Save row"]')).toBeNull(); - expect(t.container.querySelector('[data-testid="data-table-edit-column-header"]')).toBeNull(); const firstRow = t.container.querySelectorAll('tbody tr')[0] as HTMLElement; expect(firstRow.className).not.toContain('bg-amber-50'); expect(t.cell(0, 0).className).not.toContain('text-amber-700'); @@ -291,7 +290,10 @@ describe('data-table autosave — no staged fallback: a table that cannot save r expect(onRowSave).not.toHaveBeenCalled(); const lines = warn.mock.calls.map((c) => String(c[0])).filter((m) => m.startsWith('[ObjectUI] DataTable editable:')); expect(lines).toHaveLength(1); - expect(lines[0]).toMatch(/GridCellSelection/); + // The component a host mounts is the provider; `GridCellSelection` is the + // context's value type, which cannot be mounted. + expect(lines[0].match(/`GridCellSelectionProvider`/g)).toHaveLength(2); + expect(lines[0]).not.toContain('`GridCellSelection`'); }); it('under the provider with no onRowSave: no editor opens, no save bar, one console warning naming onRowSave', () => { diff --git a/ui/packages/components/src/__tests__/data-table-select-first-35684.test.tsx b/ui/packages/components/src/__tests__/data-table-select-first-35684.test.tsx index 72ef227b2e4..f075238e2b8 100644 --- a/ui/packages/components/src/__tests__/data-table-select-first-35684.test.tsx +++ b/ui/packages/components/src/__tests__/data-table-select-first-35684.test.tsx @@ -8,7 +8,7 @@ /** * `data-table`'s select-first cell model (objectstack#35684), behind the - * `GridCellSelection` a host mounts. The list page mounts it through + * `GridCellSelectionProvider` a host mounts. The list page mounts it through * `ObjectGrid`'s `cellSelection`; its keys while selected and while editing * are `data-table-keys-35687.test.tsx`. * @@ -336,7 +336,6 @@ describe('data-table select-first — a cell that opens no editor says why', () }); describe('data-table select-first — no edit-only column, ever (objectstack#35554, objectstack#35685)', () => { - const editHeader = (c: HTMLElement) => c.querySelector('[data-testid="data-table-edit-column-header"]'); const lastHeader = (c: HTMLElement) => [...c.querySelectorAll('thead th')].pop()!; // The shape `ObjectGrid` hands the list page: a save path and no row menu. const EDIT_ONLY = { rowActions: true, onRowSave: () => Promise.resolve() }; @@ -344,12 +343,10 @@ describe('data-table select-first — no edit-only column, ever (objectstack#355 it('none at rest and none after a commit: the commit saves itself', () => { const onRowSave = vi.fn(() => Promise.resolve()); const t = renderTable({ extra: { ...EDIT_ONLY, onRowSave } }); - expect(editHeader(t.container)).toBeNull(); expect(lastHeader(t.container)).toHaveTextContent('Site'); fireEvent.click(t.cell(0, 0)); fireEvent.change(t.catcher()!, { target: { value: 'A' } }); fireEvent.keyDown(t.editor()!, { key: 'Enter' }); - expect(editHeader(t.container)).toBeNull(); expect(lastHeader(t.container)).toHaveTextContent('Site'); expect(t.container.querySelector('button[title="Save row"]')).toBeNull(); expect(onRowSave).toHaveBeenCalledTimes(1); @@ -627,3 +624,38 @@ describe('data-table select-first — a read-only cell says so in the grid (obje expect(t.container.querySelector('[aria-readonly]')).toBeNull(); }); }); + +describe('data-table select-first — an injected editor keeps the model\'s keys (objectstack#35687)', () => { + // An editor opens only inside the select-first model (an `editable` table + // with no select-first host is read-only), so a host-injected editor's Tab + // and Ctrl/Cmd+Enter always follow that model. + const renderCellEditor = (ctx: { value: unknown; stage: (v: unknown) => void }) => ( +