Skip to content
Merged
4 changes: 2 additions & 2 deletions .changeset/35684-35687-list-cells-select-first.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
'@object-ui/components': minor
'@object-ui/core': minor
Expand All @@ -18,8 +18,8 @@
**The select-first cell model** (`data-table`, behind the new `GridCellSelectionProvider` in `@object-ui/components`; `ObjectGrid` mounts it when its host passes the new `cellSelection` prop, and `ListView` passes it for every `object-grid` view it draws, on the hosts listed below):

- A click selects a cell (a ring around it) and neither edits it nor opens the record. A link the cell draws (the name, a lookup, a phone or an email) keeps its own click. A touch tap opens the record and never edits in place.
- Double-click, Enter or F2 edits, keeping the value with the caret at its end; typing a character replaces the value with it (a picker or a date opens instead); Backspace or Delete opens an empty editor and saves nothing.
- While editing, Enter commits and moves down, Tab and Shift+Tab commit and move right and left, Escape cancels and keeps the cell selected; in a multi-line editor Enter is a new line and Ctrl/Cmd+Enter commits. Commits are the grid's staged edits, saved by the row's Save and Save All as before.
- Double-click, Enter or F2 edits, keeping the value with the caret at its end; typing a character replaces the value with it (a picker or a date opens instead); Backspace or Delete clears the cell and saves at once, and a required field keeps its value and says it is required (objectstack#36023).
- While editing, Enter commits and stays on the cell (objectstack#36023), Tab and Shift+Tab commit and move right and left, Escape cancels and keeps the cell selected; in a multi-line editor Enter is a new line and Ctrl/Cmd+Enter commits. Commits are the grid's staged edits, saved by the row's Save and Save All as before.
- On the selected cell the arrows and Tab move the selection, Space opens the record (a checkbox cell flips and commits instead, as a second click on it does), Ctrl/Cmd+C copies, Ctrl/Cmd+V converts the text to the field's type and commits it, and Escape clears the selection.
- An input method's composition is kept whole: keys pressed while composing, and the 229 Enter Safari raises after it, never commit, cancel or move, and a composition started on a selected cell opens the editor with the composed text. This guard applies to every `data-table` editor.
- A cell that opens no editor says why on the cell: the field is read-only, calculated or not editable in a list, the reader may not edit the field, these records or this record, the view turned editing off, or the record is locked by an approval. The approval lock is read from the approvals service's per-record lock when a cell of the row is selected, through the record page's rule (`resolveApprovalLock`); until it answers, the row's `approval_status` stands in only where the view fetches that column, which a view that authors its columns does only when a column, a row predicate or a grouping names it.
Expand Down
26 changes: 26 additions & 0 deletions .changeset/36023-cell-panel-below.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@object-ui/components': patch
'@object-ui/plugin-grid': patch
'@object-ui/fields': patch
'@object-ui/i18n': patch
---

feat(ui): in a list cell, a picker opens under the cell, Backspace clears, a refused value stays, and Enter stays on the cell

Clause-②: yes (widening)
Metadata-protocol: none

`GridCellFacts` (the select-first grid's per-cell host facts, `@object-ui/components`) gains three optional keys: `editor` (`'below'` draws the cell's editor as a panel under the cell, which keeps showing its value; absent or `'cover'`, the editor stays a layer over the cell), `clearRefusal` (why Backspace or Delete leave the cell as it is) and `validate` (why a committed value is refused). A host that sets none of them gets the editor placement and commits it had, with Backspace now clearing (below).

In every grid `ObjectGrid` draws with the select-first model (the list page):

- **Pickers open under the cell.** Single and multi select, status, tags, date, date-time, time, colour, lookup and user cells open their list, calendar or palette as a panel under the cell; the cell keeps its value as drawn (a coloured badge stays coloured) and the row height does not change. On a date the typeable box is the top of the panel and the calendar shows beneath it. Typed input, long text and an address still edit in place.
- **Backspace or Delete clears the selected cell and saves at once.** A required field keeps its value and says it is required (a required rating too, for Backspace, Delete and the 0 key); a read-only cell says why, as before; a checkbox cell is left alone.
- **A value that fails the field's rules is not saved.** The rules are the record form's (required, length, range, email and URL shape), and text a number box cannot read is refused too. The editor stays open with what was typed and says why under it (a number box that already says it cannot read its text is not told twice); correct it and commit again, or press Escape to discard. A click elsewhere does nothing while a refused value is open; a refused value whose cell scrolls out of sight is discarded.
- **A person's face no longer makes its row taller.** A user cell drew a 32 px face, which made its list row 41 px tall against 33 px for a row of text; the face is now 24 px and the row stays 33 px, at rest and while the cell is edited.
- **The selected cell's frame stays under the frozen columns** when the cell scrolls beneath them, and a cell deselected with Escape is left with no focus ring.
- **Enter saves and keeps the same cell selected**, with the focus back on it. It used to save and move the selection one row down. Tab and Shift+Tab still save and move right and left.

`@object-ui/i18n` adds `table.cellNotNumber` and `table.cellInvalid` in every locale.

Forms, dialogs and the record page keep their current controls.
18 changes: 14 additions & 4 deletions content/docs/frontend/plugins/plugin-grid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,20 @@ object and the view does not declare `userActions.editInline: false`, and
into the editor in the same place and at the same size.
- **Editing** starts on a double-click, Enter or F2 (the value kept, caret at
its end), or by typing, which replaces the value; an input method's
composition is kept whole. Backspace or Delete opens an empty editor and
saves nothing yet.
- **While editing**, Enter commits and moves down, Tab / Shift+Tab commit and
move right / left, and Escape cancels and keeps the cell selected. In a
composition is kept whole. Backspace or Delete clears the cell and saves at
once; a required field keeps its value and says it is required.
- **Where the editor draws** (objectstack#36023): a picker (single and multi
select, status, tags, date, date-time, time, colour, a lookup or a user)
opens as a panel under the cell, which keeps showing its value; the date
panel has the typeable box on top and the calendar beneath. Typed input,
long text and an address edit in place over the cell.
- **A value that fails its rules is not saved**: the field's required, length,
range, email or URL rule, or text a number box cannot read. The editor stays
open with what was typed and says why under it; correct it and commit again,
or press Escape to discard. A click elsewhere does nothing meanwhile.
- **While editing**, Enter commits and keeps the same cell selected, Tab /
Shift+Tab commit and move right / left, and Escape cancels and keeps the cell
selected. In a
multi-line editor Enter is a new line and Ctrl/Cmd+Enter commits. A click
elsewhere commits.
- **Selected cell keys:** the arrows and Tab move the selection; Space is typed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ describe('data-table — typed values edit flat in the cell; a rating is set in
expect(layer.className).toContain(':not([data-in-cell-input])]:h-8');
});

function renderRating() {
function renderRating(facts: Record<string, unknown> = {}) {
const onCellChange = vi.fn();
const t = renderTable(
{
Expand All @@ -230,7 +230,7 @@ describe('data-table — typed values edit flat in the cell; a rating is set in
data: [{ id: '1', name: 'Alpha', score: 2 }],
onCellChange,
},
{ describeCell: (_row, key) => (key === 'score' ? { stars: 5 } : null) },
{ describeCell: (_row, key) => (key === 'score' ? { stars: 5, ...facts } : null) },
);
return { ...t, onCellChange };
}
Expand All @@ -250,6 +250,20 @@ describe('data-table — typed values edit flat in the cell; a rating is set in
expect(t.editorLayer()).toBeNull();
});

it('a required rating is never cleared: 0, Backspace and Delete keep its stars and say why (objectstack#36023)', () => {
const t = renderRating({ clearRefusal: 'Score is required' });
fireEvent.click(t.cell(0, 1));
for (const key of ['0', 'Backspace', 'Delete']) {
fireEvent.keyDown(t.catcher(), { key });
expect(t.onCellChange).not.toHaveBeenCalled();
expect(document.querySelector('[data-testid="cell-readonly-reason"]')).toHaveTextContent('Score is required');
expect(t.cell(0, 1).querySelectorAll('[data-rating-star][data-filled]')).toHaveLength(2);
}
// CONTROL: a digit above zero still sets the stars on a required rating.
fireEvent.keyDown(t.catcher(), { key: '4' });
expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', 4, expect.anything());
});

it('Enter, F2 and a double-click open no editor on a rating', () => {
const t = renderRating();
fireEvent.click(t.cell(0, 1));
Expand Down
Loading
Loading