Skip to content

Commit 13d1e95

Browse files
feat(ui): in a list cell, a picker opens under the cell, Backspace clears, a refused value stays, and Enter stays on the cell (#36023 S4) (#36054)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuYSfiVTtk3DgbcGUxvr9M3o)_ repo:objectstack#1 · os-sales · session_01L6bhgTBQ7DZYZt5GQadGKZ Part of #36023 (slice S4: pop-up panels under the cell and the keyboard rules. The card stays open: the rich-text panel, the related-list tab and the long-text / address placement are recorded on #36023 by the seat, which closes the card when they are delivered or moved) Clause-②: yes (widening) — `GridCellFacts` (`@object-ui/components`, `dist/context/gridCellSelection.d.ts`) gains three optional keys: `editor`, `clearRefusal`, `validate`. Nothing is removed or narrowed; a host that sets none of them keeps its editor placement and commits. Metadata-protocol: none ## 维护者速读 - **选择型格子的面板开在格子下方**:单选、多选、状态、标签、日期、日期时间、时间、颜色、关联、人员,按回车或双击后,列表/日历/色板出现在格子正下方,格子本身照常显示原值(彩色标签还是彩色的),整行高度不变(实测 33 → 33)。日期的可输入框移到面板顶部,日历就在它下面。长文本、地址、普通输入框仍在原格编辑。 - **退格 / Delete 直接清空并立即保存**。必填字段不清空,格子上提示「××为必填」;只读格照旧说明原因;复选框格不受影响。 - **不合规的值不保存**:规则和记录表单一样(必填、长度、范围、邮箱和网址格式),数字框里读不出数字的文本也拒绝。编辑框保持打开,留着刚输入的内容,下方写明原因;改对再提交,或按 Esc 放弃。拒绝状态下点别处不生效。 - **回车保存后留在原格**(Sales 裁定 D2,7060745834)。这**反转了已合并的 #35687「回车保存并下移」**,单独一个 commit;Tab / Shift+Tab 仍保存并右移 / 左移。 - **选中框不再画到冻结列上**,Esc 取消选中后不再留下浏览器默认的(macOS 上是橙色的)焦点框。 - **人员头像不再撑高行**:原来 32px 头像让行高变 41px,编辑时又掉回 33(行高跳动);现在头像 24px,行高始终 33。 - 表单、对话框、记录页的控件不变。手机宽度(375)列表画成卡片,没有格子,本切片不涉及。 ## What changes **Host facts** (`@object-ui/components`, `context/gridCellSelection.tsx`). `GridCellFacts` gains: - `editor?: 'cover' | 'below'` — `below` draws the cell's editor as a panel under the cell, which keeps drawing its value; absent or `cover` keeps the layer over the cell. - `clearRefusal?: string | null` — why Backspace / Delete leave the cell as it is. - `validate?: (value) => string | null | undefined` — why a committed value is refused. The table cannot tell a select column from a text one (`TableColumn.type` has eight literals), so the placement is a host signal. `ObjectGrid.describeCell` (`objectGridCellFacts.ts`) answers all three from the field definition: `inlineEditorPlacement(type)` (select, status, radio, multiselect, checkboxes, tags, date, datetime, time, color, lookup, master_detail, user, owner → `below`), `clearRefusalText` (a required field; `required_message` or `validation.required`), and `cellValueRefusal`, which reads the record form's own `buildValidationRules` (required, min/max length, min/max, email / URL pattern) and says each with the form's sentence. **Panel under the cell** (`dataTableCellOverlay.tsx`, `data-table.tsx`). `CellOverlay` takes `placement`; `below` offsets the layer 2px under the cell instead of minus the cell's height, and the cell keeps its drawn value while the panel is open. No preview size is seeded for a panel. **Date panel** (`@object-ui/fields`, `DatePickerField.tsx`). The in-cell face is one panel: the typeable box on top, the calendar always showing beneath it (the panel root gives it the panel's surface and centres it over the quick picks; the calendar's own `className` literal stays as the phone-touch spec reads it), then the time row (datetime) and Today / Tomorrow / Next week / Clear. The form face is unchanged. **Backspace / Delete** on a selected cell write `null` through the same `writeCell` path a paste uses (confirm, stage, save), except a two-state cell (nothing written) and a cell with `clearRefusal` (its sentence shows on the cell; nothing written). A read-only cell says why, as before. **A refused commit** — `saveEdit` now returns whether it committed. Before staging, the select-first table asks `editRefusalOf`: first the browser's own reading of the editor's inputs (`validity.badInput` / `typeMismatch` → `table.cellNotNumber`, `validation.email`, `validation.url`, `table.cellInvalid`), then the host's `validate`. A refusal keeps the editor open with what was typed, puts the focus back in it and draws the reason under it (`role="alert"`, `data-testid="cell-edit-refusal"`). Enter / Tab do not move; a press outside is swallowed (pointerdown and its click); Escape discards. The refusal line hides as soon as the value is edited. **Enter stays on the cell** (own commit `383cbb2a`). `commitMoves` replaces `moveSelection`: Enter commits and refocuses the selected cell; Tab / Shift+Tab commit and move right / left. **Frame and focus ring.** The selected cell's frame is a child span (`data-slot="cell-selection-frame"`, `absolute inset-0 border-2 border-primary`, `z-[1]`) instead of the cell's outline: an outline painted over a frozen column the cell had scrolled under, a child paints in the cell's layer, which the sticky `z-10` columns cover. Select-first cells are `outline-none`, so the cell that keeps the focus after Esc deselects shows no ring. **User cell face** (`@object-ui/fields`, `UserCellRenderer`). The avatar is `size-6 -my-0.5` (24px drawn, 20px laid out) in both the single and the stacked branch, so it is no taller than the cell's line of text. `@object-ui/i18n` adds `table.cellNotNumber` and `table.cellInvalid` in all 11 packs (zh-Hant regenerated with `scripts/gen-zh-hant.mjs`). ## Reversal of #35687 (merged), named per the ruling Two #35687 behaviours are reversed: 1. **Enter in an editor saves and moves down → saves and stays on the cell** (Sales D2, 7060745834). 2. **Backspace / Delete open an empty editor without saving → clear and save at once; a required field refuses** (#36023 S4 scope item 3). Tests migrated (`ui/packages/components/src/__tests__/data-table-keys-35687.test.tsx`): - "Enter commits and moves down …": now expects the selection to stay on `0:0` with the focus on the cell, then Tab → `0:1`, Shift+Tab → `0:0`. - The multi-line editor case: Ctrl/Cmd+Enter commits and stays (`0:2`). - "Backspace opens an empty editor" removed; replaced by the clearing cases below. Sentences on #35687 to reword (the seat edits the card text): | Where on #35687 | Now reads | Reword to | |---|---|---| | 要做的 › 编辑时 | 回车:保存并下移一格。 | 回车:保存并留在原格。 | | 要做的 › 未编辑 | 退格、Delete:进入编辑并清空,不直接保存。 | 退格、Delete:清空并立即保存;必填字段不清空并提示。 | | 验收 (Safari / Chrome pinyin) | …单元格里是「中」字并仍在编辑;再按回车才保存。 | …单元格里是「中」字并仍在编辑;第二次回车保存并留在原格。 | | 验收 | 编辑中按 Tab:保存并选中右边一格;按回车:保存并选中下面一格。 | 编辑中按 Tab:保存并选中右边一格;按回车:保存并留在原格。 | | 验收 | 选中必填的金额格按退格:进入编辑且为空,没有发保存请求。 | 选中必填格按退格:值不变,格上提示必填,没有发保存请求。 | ## Tests - `data-table-keys-35687.test.tsx`: new describe "clearing, the panel under the cell, a refused commit (objectstack#36023)", 10 cases — Backspace / Delete clear and save; a `clearRefusal` keeps the value and says why; a two-state cell writes nothing; a read-only cell is not cleared; `below` vs `cover`; a host refusal keeps editor and input and Enter does not move, then Tab after correcting moves; Escape after a refusal discards; `badInput` refused by the table; a press outside a refused injected editor is swallowed (control: an accepted value commits); the frame is a child under frozen columns and Esc leaves no ring. - `data-table-select-first-35684.test.tsx`: the ring assertion reads the frame child instead of `outline-primary`. - `objectGridCellFacts-35684.test.ts`: placement per type, `clearRefusalText`, `cellValueRefusal` (required, length, range, pattern, messages). - `ObjectGrid.cellSelection-35684.test.tsx`: a select cell opens below and keeps its value; a required cell refuses Backspace; a `maxLength` refusal keeps the editor. - New `userCell.rowHeight-36023.test.tsx`: single and stacked faces are `size-6 -my-0.5`, never `size-8`. - Local runs: `@object-ui/components` + `@object-ui/plugin-grid` full (793 files) passed; `@object-ui/fields` + `@object-ui/i18n` full 6723 passed / 20 skipped; form-field channel census (3 files, 141) passed; `turbo run type-check` for components, fields, plugin-grid, i18n: 57/57; eslint on every changed file: 0 errors; `check:i18n`, `check:i18n-coverage`, `check:i18n-walk-parity`, `check:i18n-stale-fill`, `check:i18n-keys`, `check:i18n-dead-keys`: pass. ## Verification (browser) Showcase field zoo, a temporary 22-column probe view with the name column frozen (not in this PR), Chromium, light and dark, 1280 and 768. Shots: `/mnt/project-files/build-seat1/36023/S4/shots/`. | Kind | Placement | Row before → while open | Panel top vs cell bottom | |---|---|---|---| | date, datetime, time | below | 33 → 33 | 227 vs 225 | | select, multi-select, tags | below | 33 → 33 | 227 vs 225 | | colour | below | 33 → 33 | 227 vs 225 | | lookup, user | below | 33 → 33 | 227 vs 225 | | long text, address, email | cover (in place) | 33 → 33 | — | The same at 768 (date, select, multi-select, user) and in dark (date, select, tags, colour, long text). At 375 the list draws as cards, so there is no cell to edit. Keyboard journeys (1280): Enter on a text cell saves and stays (`1:2`, focus on the cell), Tab moves to `1:3`; number "1e" is refused with "Enter a number.", a click away keeps the editor, Esc restores 420; Backspace on phone clears it to "—"; Backspace on the required name says "Name is required"; Esc twice leaves no outline (`outline-style: none`, was the browser's `auto` ring). Frozen column: a selected cell scrolled under the frozen name column — before, its outline was drawn over the name column; after, the frame is clipped at the column's edge like the cell's text (`frozen-1-2-scrolled.png`). User face: a row holding "Dev Admin" — before 41px at rest and while editing, face 32px; after 33px at rest, while editing and after Esc, face 24px (`avatar-after-rest.png`). ## Acceptance notes - **Required rating, handed over from S3 (done after #36045 merged).** `main` is merged in (S3 1c87956). The rating's Backspace / Delete and the `0` key all go through `clearCell` (`setStars(0)` is a clear), so a required rating keeps its stars and says it is required; a digit above zero still sets the stars. Pinned in `data-table-cell-overlay-35688.test.tsx` ("a required rating is never cleared: 0, Backspace and Delete …"), next to S3's own rating cases, which pass unchanged. - **No second sentence for a number box.** S3's in-cell number, currency and percent boxes draw their own bad-input line under the box and mark it `aria-invalid`. For such a box the table refuses the commit without adding its own line (`editRefusalOf` returns `''`), so the reader sees one reason, not two. Pinned in `data-table-keys-35687.test.tsx`. - **DELIBERATE CORRECTION of a pending release note** (`Check Changeset` stays red on it by design; the seat confirms it by its own record). Note: `.changeset/35684-35687-list-cells-select-first.md` (from #35747, not yet released). This PR changed the behaviour two of its sentences describe, so they are rewritten in commit df048a4 rather than left false in the same release: - "Backspace or Delete opens an empty editor and saves nothing." → "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 moves down, Tab and Shift+Tab commit and move right and left, …" → "While editing, Enter commits and stays on the cell (objectstack#36023), Tab and Shift+Tab commit and move right and left, …" Nothing else in that note changes; restoring it from the base would republish the two false sentences. - The lookup and user record lists inside the panel are S3's (#36045); this slice only places them below. - A refused value whose cell scrolls out of sight is discarded (the scroll-away path closes the editor as before, and a refused value is not saved). - While a refused value is open, a press outside does nothing (pointerdown and the click it starts are swallowed for one second at most). - Overlap: the release PR #35129 rewrites the same pending changeset and regenerates itself. S3 #36045 has merged and `main` is merged in here (conflicts in `data-table.tsx`, the Backspace / digit branch, and `dataTableCellOverlay.tsx`, the layer classes, resolved by keeping both sides). #36033 still overlaps `data-table.tsx`; the second of the two to land merges `main`. ## How to try it Open any object list, select a select or date cell and press Enter (the panel opens under the cell; the cell still shows its value). Press Backspace on an optional cell (cleared and saved) and on a required one (refused with a hint). Type a too-long value into a text field with a max length and press Enter (the editor stays and says why). ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. (not touched) - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes. - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: n/a. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English (the 维护者速读 block and the #35687 sentences are in the maintainer's language). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgTBQ7DZYZt5GQadGKZ)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgTBQ7DZYZt5GQadGKZ <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgTBQ7DZYZt5GQadGKZ --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent eebb893 commit 13d1e95

28 files changed

Lines changed: 857 additions & 192 deletions

‎.changeset/35684-35687-list-cells-select-first.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Skills-docs: none — `skills/objectstack-ui/rules/list-views.md` already teache
1818
**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):
1919

2020
- 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.
21-
- 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.
22-
- 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.
21+
- 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).
22+
- 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.
2323
- 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.
2424
- 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.
2525
- 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.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
'@object-ui/components': patch
3+
'@object-ui/plugin-grid': patch
4+
'@object-ui/fields': patch
5+
'@object-ui/i18n': patch
6+
---
7+
8+
feat(ui): in a list cell, a picker opens under the cell, Backspace clears, a refused value stays, and Enter stays on the cell
9+
10+
Clause-②: yes (widening)
11+
Metadata-protocol: none
12+
13+
`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).
14+
15+
In every grid `ObjectGrid` draws with the select-first model (the list page):
16+
17+
- **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.
18+
- **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.
19+
- **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.
20+
- **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.
21+
- **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.
22+
- **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.
23+
24+
`@object-ui/i18n` adds `table.cellNotNumber` and `table.cellInvalid` in every locale.
25+
26+
Forms, dialogs and the record page keep their current controls.

‎content/docs/frontend/plugins/plugin-grid.mdx‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,20 @@ object and the view does not declare `userActions.editInline: false`, and
406406
into the editor in the same place and at the same size.
407407
- **Editing** starts on a double-click, Enter or F2 (the value kept, caret at
408408
its end), or by typing, which replaces the value; an input method's
409-
composition is kept whole. Backspace or Delete opens an empty editor and
410-
saves nothing yet.
411-
- **While editing**, Enter commits and moves down, Tab / Shift+Tab commit and
412-
move right / left, and Escape cancels and keeps the cell selected. In a
409+
composition is kept whole. Backspace or Delete clears the cell and saves at
410+
once; a required field keeps its value and says it is required.
411+
- **Where the editor draws** (objectstack#36023): a picker (single and multi
412+
select, status, tags, date, date-time, time, colour, a lookup or a user)
413+
opens as a panel under the cell, which keeps showing its value; the date
414+
panel has the typeable box on top and the calendar beneath. Typed input,
415+
long text and an address edit in place over the cell.
416+
- **A value that fails its rules is not saved**: the field's required, length,
417+
range, email or URL rule, or text a number box cannot read. The editor stays
418+
open with what was typed and says why under it; correct it and commit again,
419+
or press Escape to discard. A click elsewhere does nothing meanwhile.
420+
- **While editing**, Enter commits and keeps the same cell selected, Tab /
421+
Shift+Tab commit and move right / left, and Escape cancels and keeps the cell
422+
selected. In a
413423
multi-line editor Enter is a new line and Ctrl/Cmd+Enter commits. A click
414424
elsewhere commits.
415425
- **Selected cell keys:** the arrows and Tab move the selection; Space is typed

‎ui/packages/components/src/__tests__/data-table-cell-overlay-35688.test.tsx‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ describe('data-table — typed values edit flat in the cell; a rating is set in
212212
expect(layer.className).toContain(':not([data-in-cell-input])]:h-8');
213213
});
214214

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

253+
it('a required rating is never cleared: 0, Backspace and Delete keep its stars and say why (objectstack#36023)', () => {
254+
const t = renderRating({ clearRefusal: 'Score is required' });
255+
fireEvent.click(t.cell(0, 1));
256+
for (const key of ['0', 'Backspace', 'Delete']) {
257+
fireEvent.keyDown(t.catcher(), { key });
258+
expect(t.onCellChange).not.toHaveBeenCalled();
259+
expect(document.querySelector('[data-testid="cell-readonly-reason"]')).toHaveTextContent('Score is required');
260+
expect(t.cell(0, 1).querySelectorAll('[data-rating-star][data-filled]')).toHaveLength(2);
261+
}
262+
// CONTROL: a digit above zero still sets the stars on a required rating.
263+
fireEvent.keyDown(t.catcher(), { key: '4' });
264+
expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', 4, expect.anything());
265+
});
266+
253267
it('Enter, F2 and a double-click open no editor on a rating', () => {
254268
const t = renderRating();
255269
fireEvent.click(t.cell(0, 1));

0 commit comments

Comments
 (0)