Skip to content

Commit 1c87956

Browse files
feat(fields): typed values edit flat in their list cell, record pickers open in place, a rating is set by key (#35688 S3) (#36045)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> Fixes #35688 Part of #36023 Fixes #35794 _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4Uu4DWfHGqeYFBSRSfZ4TnYTH)_ repo:objectstack#1 · os-sales · session_01L6bhgTJobxYSxskrNbCuHE Slice S3 of #35688 (S1 #35990 and S2 #36018 merged), folded with the in-place input part of #36023. #36023's remaining work, which this PR leaves alone, runs in parallel slices: S4 covers Enter/Esc, panels below the cell and the validation popover; S5 covers the form line-item grid. #35794's two text fixes ride along (claimed into this PR, comment 7061527510). Clause-②: yes (widening): `GridCellFacts` (exported from the `@object-ui/components` entry) gains one optional key, `stars?: number`, measured on the built `dist/context/gridCellSelection.d.ts`. Nothing is removed or narrowed. No i18n key is added. Metadata-protocol: none ## 维护者速读 - 列表里编辑文本、邮箱、电话、网址、数字、金额、百分比:格子本身变成输入框,高度就是一行,没有圆角、阴影和内框,只剩选中格那圈 2px 边。字多了向右变宽,盖住右边的格子,但不挤动它们,行高不变。 - 数字、金额、百分比靠右对齐,显示原始数字。金额前面标币种(如 USD),百分比显示「50 %」,去掉了滑块。 - 查找、主从、用户字段:进入编辑直接展开可搜索的列表(最近用过的在前),点一下就保存。列表下方有「浏览全部记录」(打开完整选择器)和「清空」。 - 评分:选中格子后直接按数字 1–5 设星,0 或退格清空;在已选中的格子里点第几颗星就是几星。不弹编辑框。 - 富文本、公式、自动编号、附件:按回车会提示原因(例如「列表里不能编辑,请打开记录」)。 - 「最近用过」按登录用户分开记录,同一浏览器里两个账号不再共用。 - 回车和 Esc 的行为、面板位置、校验提示不在这个 PR 里,由并行的 S4 处理(Sales 09:40 已定:回车保存并留在原格;多选和标签按 Esc 仍是放弃)。 ## What changes **Flat in-cell input face** (`@object-ui/fields`): - New `InCellTextInput` (`widgets/InCellTextInput.tsx`, not on the package entry). Its height is the layer's anchor height less the 2px frame, with no border, fill or radius, 13px text and the cell's inset. An invisible copy of the text sizes the box and the input lies over it, so the `w-max` layer widens to the right without the input's intrinsic width inflating it. Props: `align` (`end` = right-aligned tabular digits), `leading` and `trailing` (muted adornments), and `below` (a refusal line inside the layer). - `TextField` (except password, textarea and currency-code branches), `EmailField`, `PhoneField`, `UrlField`, `NumberField`, `CurrencyField` and `PercentField` draw it when `inCell` is set: - Number, currency and percent are `type="number"`, right-aligned, and keep `readBadInput` and the `BadInputMessage` refusal (drawn under the row). - Currency puts its code first, keeps blur rounding and draws no home-amount preview in the cell. - Percent shows points, draws `%` after and has no slider. - `RatingField` `inCell`: smaller stars in a 28px row, no "n / max" caption. `RatingCellRenderer` stars carry `data-rating-star={n}`. **Layer** (`@object-ui/components`, `dataTableCellOverlay.tsx`): - `has-[[data-in-cell-face=input]]` drops the layer's padding, radius and shadow, keeps a 2px border on the page background, and sets its minimum height to the anchor height. - Radius and shadow carry `!`, because the console theme rounds and lifts every `[role=dialog]` with `!important` (`apps/console/src/index.css`), and the layer is a Radix popover. An important utility sits in a cascade layer and outranks the unlayered rule. This was found in the browser and is not reproducible in jsdom. - The density rule that sets inputs to `h-8` skips `[data-in-cell-input]`. **Grid** (`data-table.tsx`, `ObjectGrid.tsx`): - The built-in number and text editors use the same flat face, with numbers right-aligned. - `builtInEditorWidthClass` and `cellEditorWidthClass`: - The typed kinds start at `w-full`, the cell's own width, where S1 had `min-w-40`. - Select, status, date and datetime keep `min-w-56`. - Rating on a select-first grid: - `describeCell` adds `stars` (the field's `max`, default 5) for `rating` fields. - `attemptEdit` opens no editor for such a cell. - A digit sets `min(digit, stars)`, and 0 clears. A digit sets at most 9, so the top of a wider scale is set by a click. The `stars` fact is floored before its `> 0` test. - Backspace and Delete clear. - A click on a `data-rating-star` of the already selected cell sets that count. - Every one of these writes through `writeCell`, so it saves and undoes like any cell write. **Record pickers** (`LookupField`, `PeoplePicker`, `recentLookups`): - `LookupField` with `inCell` (and not disabled) renders its panel body inline in the layer, not in a portal popover, because the layer's focus loop would take focus back from a portal. - Search variant: `PeoplePicker` gets the new `embedded` prop. - Classic variant: the same body as the form popover, with recents, results, show-all and quick-create. - After the list come Browse all records (`browse-all-records`, gated by `dependsOn` like the form's button) and Clear (`lookup-in-cell-clear`, while a value is held). A single pick in Browse all's dialog ends the edit as a list pick does: `handleDialogSelectRecords` calls `onCommit` after the declared targets fill. A multiple pick stages. - A `dependsOn` gate shows as a hint in place of the list (`lookup-in-cell-gated`). - A single pick calls `onChange`, then `onCommit`. A multiple pick stages. Enter that picks calls `stopPropagation`, so the grid's wrapper does not commit a second time with the pre-pick value. - `recentLookups` keys the ring as `<prefix><userId>:<object>` when a user is signed in (`usePermissions().userId`). With no user, the key is unchanged. Rings stored under the old object-only key are not read, so a signed-in user's recents start empty once after the upgrade. **Text (#35794)**: `docs/qa/platform-checklist/areas/records-forms.json`. `form-view-gallery` and `v18-semantic-defaults` move to revision 9, with history entries, and now describe the select-first list with no switch. `examples/app-showcase` Task Desk text: "Click a task's title to edit it in a drawer". ## Why Card #35688 sets this target: - Typed values are edited in the cell. - Numbers are raw and right-aligned. - Currency shows its code, and percent has no slider. - A lookup or user opens its searchable list at once and commits on the pick. - A rating is set in place. - Read-only kinds say why they can't be edited. #36023 adds that the row height does not change and the cell itself is the input, with no inner box. S1 put every editor on a layer over its cell, and S2 gave the pickers their in-cell faces. This slice gives the remaining kinds theirs. ## Tests - New in `ui/packages/fields/src/__tests__/inCellFaces-35688.test.tsx`: - The seven typed faces are flat, with alignment, code, `%` and no slider, and a bad number refusal. - Rating `inCell`. - The in-cell record picker opens at once, a pick commits, multiple stages, and Enter does not reach the grid. - The people picker is embedded. - Clear. - CONTROL form faces for text, number and lookup. - New in `ui/packages/fields/src/widgets/recentLookups.test.ts`: per-user rings, and the CONTROL key with no user. - New in `ui/packages/components/src/__tests__/data-table-cell-overlay-35688.test.tsx`: - The layer drops padding, radius and shadow for the input face. - Rating digits, Backspace and the star click on a selected cell. - Enter, F2 and double-click open no editor for a rating. - CONTROL: a non-rating cell still opens its editor on a digit. - Changed in the same file: test 3 now expects no `min-w-40` on a typed editor. The typed kinds now start at the cell's width. - New in `ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx` (real `ObjectGrid` → `data-table` → fields): a lookup pick ends the edit; a single pick in Browse all's dialog closes the editor and saves `{ tier: 'silver' }` through `ds.update` (fails with the commit removed); a rating digit saves through `ds.update`. - Changed in `ui/packages/plugin-grid/src/__tests__/gridDependentValues-7165.test.tsx`, `lookupPickerKeys-7154.test.tsx` and `relationalMetaCopySet-7166.test.tsx`: - The cell's lookup editor is now the open list, with no trigger button to press, so `openEditor` returns the in-cell panel and Escape is sent where focus is. - Every claim stays, with its control: `dependsOn` gates (hint, Browse all disabled, no options) and scopes the query; `multiple` accumulates (two `aria-selected` rows) while single replaces; `allowCreate`; `lookupPageSize` through Browse all (3 rows against the default 10); and `descriptionField`, `lookupColumns` and `lookupFilters`. - No case deleted. - Changed in `ui/packages/plugin-grid/src/__tests__/inlineEditExitMode.test.tsx`: the two lookup exit-mode cases pinned the popover era, where a pick staged and a click outside committed. They now pin the in-cell list: a pick lands and closes the editor, a press inside the open list keeps it, and a press outside exits (CONTROL). The four text-editor cases are unchanged. - Changed in `ui/examples/schema-catalog/test/form-field-channel-census-12130.test.tsx`: the `inCell` and `onCommit` ledger rows name the 13 widgets that now read them. - Local runs (before the last Browse all and theme commits): | Package | Result | |---|---| | `@object-ui/fields` | 4,780 passed, 7 skipped | | `@object-ui/components` | 4,798 passed, 24 skipped | | `@object-ui/plugin-list` | 1,965 passed | | `@object-ui/plugin-grid` | 2,610 passed, 11 failed | The 11 plugin-grid failures were the three picker suites above. After the fix they pass (14 of 14), and `inCellFaces-35688` with the grid routing test passes (34). The overlay test passes after the theme fix (12). - `tsc --noEmit` is clean for fields, components and plugin-grid. eslint on the changed files: 0 errors. - `node scripts/check-platform-checklist.mjs` passes. ## Acceptance notes - The S3 claim leaves out Enter and Esc behaviour, panel position and look, and the validation popover. Sales ruled at 09:40Z, for S4: Enter saves and stays in the cell, and multi-select and tags Esc discards. - Rich text stays a preview plus a hint to edit on the record page (fable-reviewed D1). Rich text, formula, rollup, autonumber and attachment already say why on Enter through `grid.readOnlyReason.*`, so they need no code. Measured below. - Browser findings that predate this PR, not fixed here (the row-height one goes to S4 under #36023, comment 7062043119; the other two are on #36046): - **Row height.** A user cell's avatar (`size-8` in a `py-1` cell) makes its row 41px where other rows are 32px. Opening that cell's editor swaps the chip out, and the row drops to 32 (#36023 「行高不变」). - **Raw id after a pick.** After a user pick, the cell draws the bare id (`UnresolvedUserReference`) until the row is fetched again. A lookup to an ordinary object shows its name. - **Initials.** The people list's initials for "Ada Auditor (demo)" read "A(". - Safari and the pinyin IME are not measurable in this container. - Overlap (`scripts/pm/overlap-check.mjs`, clean): #36033 (data-table, fields index), #36026 (records-forms.json) and #36024 (ObjectGrid) all merge cleanly. S4 and S5 share data-table, ObjectGrid and LookupField; whichever lands second merges main. ## Verification Browser: showcase field zoo with a temporary 22-column view, name column frozen (not in this pull request), in Chromium. Runs at 1280 light, 1280 dark and 768 light; at 375 the list is the phone card list, with no in-cell editing. Script, screenshots and readings are in the project folder `build-seat1/35688/S3/` (`s3.cjs`, `shots/`, `browser-evidence.md`). | Reading | this branch | |---|---| | text, email, url, phone: F2 | layer = cell box exactly (x, y, width, height); radius 0, no shadow; input transparent, 13px, focused; row 32 → 32 → 32 after Esc | | text, email: type a long tail | layer widens right (176 → 406px), left edge fixed; row 32 | | number / currency / percent | right-aligned; `7`; `USD` before an empty amount; `50` with `%`; row unchanged | | rating, selected: 3, click 5th star, Backspace, 4 | 3 → 5 → 0 → 4 stars, no layer, cell stays selected, saved | | lookup (account): Enter | list 512×330, search focused, rows with preview lines, Browse all records + Clear; pick "Hooli" saves, layer closes, cell shows Hooli; row 32 | | user: Enter, pick | people list, search focused; pick saves and closes (raw id shown till reload, see notes) | | lookup: Browse all, type "Wonka" in the dialog, pick | dialog 10 rows → 1; focus stays in the dialog's search; pick closes dialog and editor, "1 row saved", cell shows Wonka Brands, row 32, kept after reload | | rich text / formula / autonumber: Enter | no layer; "This field can't be edited in a list. Open the record to change it." / "This value is calculated, so it can't be edited." / "This field is read-only." | | dark | same readings; flat face on the dark page background | Two-minute check: open any list with a number column, select a cell and press F2 (the cell itself is the box, right-aligned, row height unchanged). Then select a rating cell and press 4. ## 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 is the maintainer's summary, in the maintainer's language). - [x] The *Before Submitting* list in CONTRIBUTING.md is done. --- _Generated by [Claude Code](https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE <!-- signed: repo:objectstack#1 · os-sales · session_01L6bhgTJobxYSxskrNbCuHE --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 615d995 commit 1c87956

29 files changed

Lines changed: 1188 additions & 334 deletions
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
'@object-ui/components': patch
3+
'@object-ui/fields': patch
4+
'@object-ui/plugin-grid': patch
5+
---
6+
7+
feat(fields): typed values edit flat in their list cell, a record picker opens its list in place, and a rating is set without an editor
8+
9+
Clause-②: yes (widening)
10+
Metadata-protocol: none
11+
12+
In the list grid's cell editor (the layer over the cell, `inCell`):
13+
14+
- Text, email, phone, URL, number, currency and percent are the cell itself: one row tall, square, with no border, fill or shadow of their own, the layer's 2px frame the only line around them (square and flat even under a host theme that rounds and lifts every dialog with `!important`). The box starts as wide as its column and grows to the right with the text, over the next cells, without moving them. Numbers are right-aligned and raw (`34500.5`, not `34,500.50`); a currency shows its code before the amount; a percent shows its points and a `%`, without the slider. The grid's built-in text and number editors take the same flat look.
15+
- A lookup, master-detail or user cell opens its searchable candidate list at once (recently used first, then results); a pick is the whole edit. Under the list, Browse all records opens the full record picker (classic lookups, gated by `dependsOn` like the list), where a single pick ends the edit too, and Clear is offered while the cell holds a value.
16+
- On a select-first grid a rating opens no editor: a digit key sets that many stars (0 clears, capped at the field's scale), a click on a star of the already selected cell sets it, and Backspace or Delete clears it. `GridCellFacts` gains the optional `stars` fact a host sets for this (`ObjectGrid` sets it for `rating` fields).
17+
- The record pickers' local "recently used" ring is kept per signed-in user as well as per object, so two accounts in one browser no longer share it. Rings stored under the old object-only key are not read, so each user's recents start empty once after the upgrade.
18+
19+
Forms, dialogs and the record page draw these widgets as before. No i18n key is added.

‎docs/qa/platform-checklist/areas/records-forms.json‎

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@
962962
"title": "Form-view gallery: every FormViewSchema layout type renders and submits",
963963
"since": "v15",
964964
"status": "active",
965-
"revision": 8,
965+
"revision": 9,
966966
"priority": "P1",
967967
"surface": "browser",
968968
"personas": [
@@ -991,7 +991,7 @@
991991
"overlay the default form with the tabbed variant (type tabbed + the sections of formViews.tabbed, through the fixtures.requires[0] recipe with item-level isDefault:true); reopen the page form; verify the three tabs (Overview / Schedule / Details) and that switching tabs preserves entered values",
992992
"overlay the default form with the wizard variant; open the PAGE form (…/showcase_task/new, or the record's /edit route — RecordFormPage passes the type in both modes); walk Basics → Assignment → Schedule with next/back; verify back preserves values and submit happens ONCE at the end. The New/Edit MODAL renders a wizard as a stacked section list by design (resolveFormViewLayout), so the steps are walked on the page route",
993993
"RETIRED-TYPE refusal: put the default-form overlay of fixtures.requires[0] with type 'split', then 'drawer', then 'modal' (any sections), and capture each refusal: a 422 whose message names the retired value with its prescription (FORM_VIEW_TYPE_RETIRED). Record whether the draft PUT or its publish answered it. Then re-read GET /api/v1/meta/view/showcase_task.form and confirm none of the three landed. There is no split pane to look for: the showcase's formViews.split is now a two-tab tabbed form",
994-
"drawer and modal: open task-desk.page.ts; click a task row — ObjectForm formType=\"drawer\" opens as a side panel over the list with the task's fields; click New task — ObjectForm formType=\"modal\" opens as a dialog. These are the React block's containers, which ADR-0050 keeps (the block is the caller that opens the form); a form view can no longer name either (steps[3])",
994+
"drawer and modal: open task-desk.page.ts; click a task's title (or select one of its cells and press Space) — ObjectForm formType=\"drawer\" opens as a side panel over the list with the task's fields; click New task — ObjectForm formType=\"modal\" opens as a dialog. These are the React block's containers, which ADR-0050 keeps (the block is the caller that opens the form); a form view can no longer name either (steps[3])",
995995
"on the simple form, set priority to 'urgent' and verify the notes field appears (FormField.visibleWhen CEL); set it back and verify notes hides",
996996
"save an edit through each rendered variant; capture each save request; re-read via GET /api/v1/data/showcase_task/<id>. The page form's /new and /edit routes are reached by URL only: the record page's Edit opens the form as a modal (?form=ID, footer 'Update'), not the page (QA run #33861). A deep-linked page form saves and stays in the app: RecordFormPage's goBack goes back one entry only when the console pushed one (history.state.idx above 0) and otherwise replaces to the record page (edit) or the list (create) (ui/packages/app-shell/src/views/RecordFormPage.tsx)",
997997
"revert the default-form overlay so the stock simple form is back — DELETE /api/v1/meta/view/showcase_task.form, the reset door, which restores the artifact default byte-identically (QA run #24572) — and confirm it with a re-read of the view"
@@ -1097,6 +1097,12 @@
10971097
"date": "2026-11-15",
10981098
"change": "steps[6] re-pointed: the record page's Edit opens a modal (?form=ID), so the page routes are reached by URL (QA run #33861, ledger row 140), and a deep-linked page form no longer leaves the document on save (RecordFormPage goBack replaces to the record or the list when nothing was pushed). No clause changed. Ledger 6896511848 of the v18.5.0 sweep anchor #33761, carried by batch-A card #33963; read at base 895783a1.",
10991099
"ref": "#33990"
1100+
},
1101+
{
1102+
"revision": 9,
1103+
"date": "2026-11-21",
1104+
"change": "steps[4] opens the edit drawer from a task's title link, or Space on a selected cell: the list is select-first since #35684, so a click on an assignee, status or priority cell only selects it. No clause changed. Read at base c00be39b",
1105+
"ref": "#35794"
11001106
}
11011107
]
11021108
},
@@ -6510,7 +6516,7 @@
65106516
"title": "Defaults that changed meaning on v18 (ADR-0087 D3 18.* entries): an omitted list-view page size is 50 (was 25), an omitted editInline means editable in place, an autonumber with no `unique` is unique per organization, and a field-heavy form opens as a bounded modal on desktop",
65116517
"since": "v18",
65126518
"status": "active",
6513-
"revision": 8,
6519+
"revision": 9,
65146520
"priority": "P2",
65156521
"surface": "mixed",
65166522
"personas": [
@@ -6530,8 +6536,8 @@
65306536
]
65316537
},
65326538
"steps": [
6533-
"GET /api/v1/meta/view/VIEW to confirm the view declares no pagination and no userActions block — the meta read serves the authored view, so nothing resolved can be read there; the defaults show only in the renderer (the list request's top=50, the Edit inline switch). Seed more than 50 rows on the object whose list you count first (fixtures.requires[2]: no stock object holds that many), then open the list in the console and count the first page",
6534-
"as a member who may update, open the list and confirm the inline-edit affordance — the 'Edit inline' switch in the list's Display / view-settings popover at desktop width; as a read-only member confirm it is absent. The edit mode itself is session state that starts OFF (objectui app-shell ObjectView.tsx: 'The edit mode is now session state'), so cells are not editable on load until the switch is turned on — a click on a cell opens the record before then",
6539+
"GET /api/v1/meta/view/VIEW to confirm the view declares no pagination and no userActions block — the meta read serves the authored view, so nothing resolved can be read there; the defaults show only in the renderer (the list request's top=50, cells editable in place). Seed more than 50 rows on the object whose list you count first (fixtures.requires[2]: no stock object holds that many), then open the list in the console and count the first page",
6540+
"as a member who may update, open the list and confirm the inline-edit affordance — the list is editable in place with no switch and no mode: a click on a data cell selects it, and a double-click, Enter or typing opens its editor; as a read-only member select a cell and press Enter — the cell says why it cannot be edited and no editor opens",
65356541
"create two rows of an autonumber object in the same org and read their numbers",
65366542
"open New on a field-heavy object on a desktop viewport, then on a mobile viewport"
65376543
],
@@ -6549,7 +6555,7 @@
65496555
"evidence": "row count + one-line screenshot description"
65506556
},
65516557
{
6552-
"clause": "inline edit is offered to an updater and absent for a read-only member with editInline omitted — 'offered' means the Edit inline switch is present (the edit mode starts off for the session, steps[1])",
6558+
"clause": "inline edit is offered to an updater and absent for a read-only member with editInline omitted — 'offered' means a selected cell opens its editor on Enter or a double-click, and 'absent' means the cell says why instead (steps[1])",
65536559
"oracle": "screenshot",
65546560
"verify": "per-persona affordance",
65556561
"evidence": "two one-line descriptions"
@@ -6623,6 +6629,12 @@
66236629
"date": "2026-11-19",
66246630
"change": "acceptance[1] reads 'first window' for 'first page': since #35554 a list view with no declared `pagination` draws no pager and loads its next 50 as it scrolls; the 50-row default it pins is unchanged. Read at base 93fa4f97",
66256631
"ref": "#35554"
6632+
},
6633+
{
6634+
"revision": 9,
6635+
"date": "2026-11-21",
6636+
"change": "steps[0], steps[1] and acceptance[2].clause follow #35684: the list is editable in place with no Edit inline switch and no session mode; a click selects a cell, a double-click, Enter or typing edits it, and for a read-only member the cell says why it cannot be edited. The 50-row and form-shape clauses are unchanged. Read at base c00be39b",
6637+
"ref": "#35794"
66266638
}
66276639
]
66286640
},

‎examples/app-showcase/src/ui/pages/task-desk.page.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function Page() {
3232
<div>
3333
<h1 style={{ fontSize: 24, fontWeight: 700, letterSpacing: '-0.01em', color: 'hsl(var(--foreground))', margin: 0 }}>Task Desk</h1>
3434
<p style={{ marginTop: 4, fontSize: 14, color: 'hsl(var(--muted-foreground))' }}>
35-
Click a task to edit it in a <strong>drawer</strong>; create one in a <strong>modal</strong> — both render the platform's pre-styled <code>&lt;ObjectForm&gt;</code> overlay.
35+
Click a task's title to edit it in a <strong>drawer</strong>; create one in a <strong>modal</strong> — both render the platform's pre-styled <code>&lt;ObjectForm&gt;</code> overlay.
3636
</p>
3737
</div>
3838
<button onClick={() => setCreating(true)}

‎ui/examples/schema-catalog/test/form-field-channel-census-12130.test.tsx‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,19 +310,30 @@ const LEDGER: Readonly<Record<string, LedgerRow>> = {
310310
why: 'RUNTIME SLOT — a host-supplied function; JSON has no function value (the objectui#6124 shape).',
311311
},
312312
// objectstack#35688 — the list grid's cell editor (`ObjectGrid` through
313-
// `FieldEditWidget`) sets these two; a form never does.
313+
// `FieldEditWidget`) sets these two; a form never does. The typed inputs,
314+
// rating and record pickers read them since S3 (objectstack#36023).
314315
inCell: {
315316
readers: [
316-
'props@fields/src/widgets/ColorField.tsx', 'props@fields/src/widgets/MultiSelectField.tsx',
317-
'props@fields/src/widgets/TagsField.tsx', 'props@fields/src/widgets/TimeField.tsx',
317+
'props@fields/src/widgets/ColorField.tsx', 'props@fields/src/widgets/CurrencyField.tsx',
318+
'props@fields/src/widgets/EmailField.tsx', 'props@fields/src/widgets/LookupField.tsx',
319+
'props@fields/src/widgets/MultiSelectField.tsx', 'props@fields/src/widgets/NumberField.tsx',
320+
'props@fields/src/widgets/PercentField.tsx', 'props@fields/src/widgets/PhoneField.tsx',
321+
'props@fields/src/widgets/RatingField.tsx', 'props@fields/src/widgets/TagsField.tsx',
322+
'props@fields/src/widgets/TextField.tsx', 'props@fields/src/widgets/TimeField.tsx',
323+
'props@fields/src/widgets/UrlField.tsx',
318324
],
319325
why: 'RUNTIME SLOT (objectstack#35688) — host plumbing: the grid cell editor asks for the in-cell face; where a '
320326
+ 'widget is drawn is the host\'s fact, not something a form document authors.',
321327
},
322328
onCommit: {
323329
readers: [
324-
'props@fields/src/widgets/ColorField.tsx', 'props@fields/src/widgets/MultiSelectField.tsx',
325-
'props@fields/src/widgets/TagsField.tsx', 'props@fields/src/widgets/TimeField.tsx',
330+
'props@fields/src/widgets/ColorField.tsx', 'props@fields/src/widgets/CurrencyField.tsx',
331+
'props@fields/src/widgets/EmailField.tsx', 'props@fields/src/widgets/LookupField.tsx',
332+
'props@fields/src/widgets/MultiSelectField.tsx', 'props@fields/src/widgets/NumberField.tsx',
333+
'props@fields/src/widgets/PercentField.tsx', 'props@fields/src/widgets/PhoneField.tsx',
334+
'props@fields/src/widgets/RatingField.tsx', 'props@fields/src/widgets/TagsField.tsx',
335+
'props@fields/src/widgets/TextField.tsx', 'props@fields/src/widgets/TimeField.tsx',
336+
'props@fields/src/widgets/UrlField.tsx',
326337
],
327338
why: 'RUNTIME SLOT (objectstack#35688) — a host-supplied function (the grid cell editor\'s commit); JSON has no '
328339
+ 'function value (the objectui#6124 shape).',

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

Lines changed: 89 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ afterEach(() => {
6363
}
6464
});
6565

66-
function renderTable(extra: Record<string, unknown> = {}) {
66+
function renderTable(extra: Record<string, unknown> = {}, selection: React.ComponentProps<typeof GridCellSelectionProvider>['value'] = {}) {
6767
const DataTable = ComponentRegistry.get('data-table')!;
6868
const onCellChange = vi.fn();
6969
const schema = {
@@ -82,7 +82,7 @@ function renderTable(extra: Record<string, unknown> = {}) {
8282
...extra,
8383
};
8484
const utils = render(
85-
<GridCellSelectionProvider value={{}}>
85+
<GridCellSelectionProvider value={selection}>
8686
<DataTable schema={schema} />
8787
</GridCellSelectionProvider>,
8888
);
@@ -147,7 +147,8 @@ describe('data-table — the editor and a cut-off cell draw on a layer over the
147147
// The utility that reads the seed survives the per-type floor, which rides an inner box.
148148
expect(layer.className).toContain('min-w-[max(var(--radix-popper-anchor-width),var(--cell-overlay-min-w,0px))]');
149149
expect(layer.className).not.toMatch(/(^|\s)min-w-40(\s|$)/);
150-
expect(layer.querySelector('.min-w-40')).not.toBeNull();
150+
// objectstack#36023 — a typed value takes no per-type floor: it starts at the cell's width.
151+
expect(layer.querySelector('.min-w-40')).toBeNull();
151152
fireEvent.keyDown(layer.querySelector('input')!, { key: 'Escape' });
152153
expect(t.editorLayer()).toBeNull();
153154
expect(t.previewLayer()).toBeNull();
@@ -191,3 +192,88 @@ describe('data-table — the editor and a cut-off cell draw on a layer over the
191192
expect(t.onCellChange).toHaveBeenCalledWith(0, 'name', 'Alpha 2', expect.anything());
192193
});
193194
});
195+
196+
describe('data-table — typed values edit flat in the cell; a rating is set in place (objectstack#36023)', () => {
197+
it('the built-in text editor is the flat face, and the layer drops its padding, radius and shadow for it', () => {
198+
const t = renderTable();
199+
fireEvent.click(t.cell(0, 0));
200+
fireEvent.keyDown(t.catcher(), { key: 'Enter' });
201+
const layer = t.editorLayer()!;
202+
const input = layer.querySelector<HTMLInputElement>('[data-in-cell-face="input"] input[data-in-cell-input]')!;
203+
expect(input).toHaveValue('Alpha');
204+
expect(input.className).toMatch(/\bborder-0\b/);
205+
expect(input.className).toMatch(/\brounded-none\b/);
206+
expect(input.className).not.toMatch(/(^|\s)h-10(\s|$)/);
207+
// The layer reads the marked face (`:has()` utilities, spelled in full for Tailwind).
208+
expect(layer.className).toContain('has-[[data-in-cell-face=input]]:p-0');
209+
expect(layer.className).toContain('has-[[data-in-cell-face=input]]:rounded-none');
210+
expect(layer.className).toContain('has-[[data-in-cell-face=input]]:border-2');
211+
// The form-density height skips the flat input.
212+
expect(layer.className).toContain(':not([data-in-cell-input])]:h-8');
213+
});
214+
215+
function renderRating() {
216+
const onCellChange = vi.fn();
217+
const t = renderTable(
218+
{
219+
columns: [
220+
{ header: 'Name', accessorKey: 'name' },
221+
{
222+
header: 'Score',
223+
accessorKey: 'score',
224+
// The stars the rating cell renderer draws, one hit target each.
225+
cell: (value: number) => (
226+
<span>{[1, 2, 3, 4, 5].map((n) => <svg key={n} data-rating-star={n} data-filled={n <= value ? '' : undefined} />)}</span>
227+
),
228+
},
229+
],
230+
data: [{ id: '1', name: 'Alpha', score: 2 }],
231+
onCellChange,
232+
},
233+
{ describeCell: (_row, key) => (key === 'score' ? { stars: 5 } : null) },
234+
);
235+
return { ...t, onCellChange };
236+
}
237+
238+
it('a digit on the selected rating sets that many stars, at most the scale; 0 and Backspace clear', () => {
239+
const t = renderRating();
240+
fireEvent.click(t.cell(0, 1));
241+
fireEvent.keyDown(t.catcher(), { key: '3' });
242+
expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', 3, expect.anything());
243+
fireEvent.keyDown(t.catcher(), { key: '9' });
244+
expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', 5, expect.anything());
245+
fireEvent.keyDown(t.catcher(), { key: '0' });
246+
expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', null, expect.anything());
247+
fireEvent.keyDown(t.catcher(), { key: '4' });
248+
fireEvent.keyDown(t.catcher(), { key: 'Backspace' });
249+
expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', null, expect.anything());
250+
expect(t.editorLayer()).toBeNull();
251+
});
252+
253+
it('Enter, F2 and a double-click open no editor on a rating', () => {
254+
const t = renderRating();
255+
fireEvent.click(t.cell(0, 1));
256+
fireEvent.keyDown(t.catcher(), { key: 'Enter' });
257+
fireEvent.keyDown(t.catcher(), { key: 'F2' });
258+
fireEvent.doubleClick(t.cell(0, 1));
259+
expect(t.editorLayer()).toBeNull();
260+
expect(t.onCellChange).not.toHaveBeenCalled();
261+
});
262+
263+
it('the first click on a star only selects; a click on a star of the selected cell sets it', () => {
264+
const t = renderRating();
265+
const star = (n: number) => t.cell(0, 1).querySelector(`[data-rating-star="${n}"]`)!;
266+
fireEvent.click(star(4));
267+
expect(t.cell(0, 1)).toHaveAttribute('data-selected-cell');
268+
expect(t.onCellChange).not.toHaveBeenCalled();
269+
fireEvent.click(star(4));
270+
expect(t.onCellChange).toHaveBeenCalledWith(0, 'score', 4, expect.anything());
271+
});
272+
273+
it('CONTROL: without the stars fact a digit opens the editor as typing does', () => {
274+
const t = renderTable();
275+
fireEvent.click(t.cell(0, 0));
276+
fireEvent.keyDown(t.catcher(), { key: '3' });
277+
expect(t.onCellChange).not.toHaveBeenCalled();
278+
});
279+
});

‎ui/packages/components/src/context/gridCellSelection.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,14 @@ export interface GridCellFacts {
4343
typing?: 'replace' | 'open';
4444
/** A two-state value: a click on the selected cell, or Space, flips it and commits. */
4545
toggles?: boolean;
46+
/**
47+
* A rating out of this many stars, set in place and never in an editor: on
48+
* the selected cell a digit key sets that many stars (0 clears), a click on
49+
* a star the cell draws (`data-rating-star`) sets it, and Backspace or
50+
* Delete clears it; each commits. A digit sets at most 9, so on a wider
51+
* scale the top values are set by a click.
52+
*/
53+
stars?: number;
4654
/**
4755
* The value pasted text stands for in this cell, or `undefined` when the
4856
* text is not one (Ctrl/Cmd+V on the selected cell then writes nothing).

0 commit comments

Comments
 (0)