From 41808114d88f5aec270d88fda4fb63541f4e8602 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 09:23:07 +0000 Subject: [PATCH 1/9] docs(qa): the select-first list in two checklist items and the Task Desk text Claude-Session: https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE Co-authored-by: Claude --- .../areas/records-forms.json | 24 ++++++++++++++----- .../src/ui/pages/task-desk.page.ts | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/docs/qa/platform-checklist/areas/records-forms.json b/docs/qa/platform-checklist/areas/records-forms.json index 6fd674d1d47..f794b65a639 100644 --- a/docs/qa/platform-checklist/areas/records-forms.json +++ b/docs/qa/platform-checklist/areas/records-forms.json @@ -962,7 +962,7 @@ "title": "Form-view gallery: every FormViewSchema layout type renders and submits", "since": "v15", "status": "active", - "revision": 8, + "revision": 9, "priority": "P1", "surface": "browser", "personas": [ @@ -991,7 +991,7 @@ "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", "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", "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", - "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])", + "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])", "on the simple form, set priority to 'urgent' and verify the notes field appears (FormField.visibleWhen CEL); set it back and verify notes hides", "save an edit through each rendered variant; capture each save request; re-read via GET /api/v1/data/showcase_task/. 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)", "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 @@ "date": "2026-11-15", "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.", "ref": "#33990" + }, + { + "revision": 9, + "date": "2026-11-21", + "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", + "ref": "#35794" } ] }, @@ -6510,7 +6516,7 @@ "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", "since": "v18", "status": "active", - "revision": 8, + "revision": 9, "priority": "P2", "surface": "mixed", "personas": [ @@ -6530,8 +6536,8 @@ ] }, "steps": [ - "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", - "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", + "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", + "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", "create two rows of an autonumber object in the same org and read their numbers", "open New on a field-heavy object on a desktop viewport, then on a mobile viewport" ], @@ -6549,7 +6555,7 @@ "evidence": "row count + one-line screenshot description" }, { - "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])", + "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])", "oracle": "screenshot", "verify": "per-persona affordance", "evidence": "two one-line descriptions" @@ -6623,6 +6629,12 @@ "date": "2026-11-19", "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", "ref": "#35554" + }, + { + "revision": 9, + "date": "2026-11-21", + "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", + "ref": "#35794" } ] }, diff --git a/examples/app-showcase/src/ui/pages/task-desk.page.ts b/examples/app-showcase/src/ui/pages/task-desk.page.ts index f95a0499bd0..c627150798a 100644 --- a/examples/app-showcase/src/ui/pages/task-desk.page.ts +++ b/examples/app-showcase/src/ui/pages/task-desk.page.ts @@ -32,7 +32,7 @@ function Page() {

Task Desk

- Click a task to edit it in a drawer; create one in a modal — both render the platform's pre-styled <ObjectForm> overlay. + Click a task's title to edit it in a drawer; create one in a modal — both render the platform's pre-styled <ObjectForm> overlay.

))} - - {currentValue} / {max} - + {!inCell && ( + + {currentValue} / {max} + + )} ); } diff --git a/ui/packages/fields/src/widgets/TextField.tsx b/ui/packages/fields/src/widgets/TextField.tsx index 5225413fd56..61eb6a86ebc 100644 --- a/ui/packages/fields/src/widgets/TextField.tsx +++ b/ui/packages/fields/src/widgets/TextField.tsx @@ -6,12 +6,13 @@ import { toDomProps } from './toDomProps.js'; import { PHONE_TOUCH_HEIGHT } from './touchTarget.js'; import { CurrencyCodeField, isCurrencyCodeField } from './CurrencyCodeField.js'; import { ScanFieldButton, useFieldScanOffered } from './ScanFieldButton.js'; +import { InCellTextInput } from './InCellTextInput.js'; /** * TextField - Standard single-line or multi-line text input * Automatically renders as a textarea when rows are configured in field metadata */ -export function TextField({ value, onChange, field, readonly, error, ...props }: FieldWidgetComponentProps) { +export function TextField({ value, onChange, field, readonly, error, inCell, onCommit: _onCommit, ...props }: FieldWidgetComponentProps) { const fieldData = field; // Read before any early return: hooks run in the same order on every render. const scanOffered = useFieldScanOffered(); @@ -78,6 +79,22 @@ export function TextField({ value, onChange, field, readonly, error, ...props }: } const isPassword = fieldData?.type === 'password'; + + // objectstack#36023 — in a list cell the cell itself is the input. + if (inCell && !isPassword) { + return ( + onChange(e.target.value)} + placeholder={fieldData?.placeholder} + maxLength={maxLength} + disabled={domProps.disabled} + aria-invalid={!!error} + /> + ); + } const input = ( ) { +export function UrlField({ value, onChange, field, readonly, error, inCell, onCommit: _onCommit, ...props }: FieldWidgetComponentProps) { const config = field; if (readonly) { if (!value) return ; @@ -33,6 +34,21 @@ export function UrlField({ value, onChange, field, readonly, error, ...props }: const domProps = toDomProps(props); + // objectstack#36023 — in a list cell the cell itself is the input. + if (inCell) { + return ( + onChange(e.target.value)} + placeholder={config?.placeholder || 'https://example.com'} + disabled={domProps.disabled} + aria-invalid={!!error} + /> + ); + } + return ( 0 ? Math.floor(max) : 5; +} + /** * objectstack#35688 — how wide a field type's editor layer starts. The layer * is never narrower than its cell and grows to fit this; the editor fills it. @@ -784,11 +790,17 @@ function cellEditorWidthClass(type: string): string { case 'status': case 'date': case 'datetime': + return 'w-full min-w-56'; + // objectstack#36023 — a typed input starts as wide as its cell and grows + // to the right with its text (`InCellTextInput`). + case 'text': + case 'email': case 'phone': case 'url': - case 'email': + case 'number': case 'currency': - return 'w-full min-w-56'; + case 'percent': + return 'w-full'; default: return 'w-full min-w-40'; } @@ -1326,6 +1338,8 @@ export const ObjectGrid: React.FC = ({ readOnlyReason: kind ? readOnlyReasonText(kind, t) : null, typing: inlineTyping(type), ...(type === 'boolean' || type === 'toggle' ? { toggles: true } : {}), + // objectstack#36023 — a rating is set in place: digits, or a click on a star. + ...(type === 'rating' ? { stars: ratingScaleOf(fieldDef) } : {}), ...(fromText ? { fromText } : {}), }; }, From a7119780dec81662ee156796005e962634ea98de Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 09:28:42 +0000 Subject: [PATCH 3/9] feat(fields): a lookup or user cell opens its searchable list in place Claude-Session: https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE Co-authored-by: Claude --- .../fields/src/widgets/LookupField.tsx | 377 +++++++++++------- .../fields/src/widgets/PeoplePicker.tsx | 20 +- 2 files changed, 245 insertions(+), 152 deletions(-) diff --git a/ui/packages/fields/src/widgets/LookupField.tsx b/ui/packages/fields/src/widgets/LookupField.tsx index 210c544f92a..3414c2394b2 100644 --- a/ui/packages/fields/src/widgets/LookupField.tsx +++ b/ui/packages/fields/src/widgets/LookupField.tsx @@ -356,8 +356,9 @@ function OptionPreviewLine({ children }: { children: React.ReactNode }) { * from the referenced object using `DataSource.find()`. * Falls back to static `options` when no DataSource is available. */ -export function LookupField({ value, onChange, field, readonly, error: fieldError, ...props }: FieldWidgetComponentProps) { - const [isOpen, setIsOpen] = useState(false); +export function LookupField({ value, onChange, field, readonly, error: fieldError, inCell, onCommit, ...props }: FieldWidgetComponentProps) { + // objectstack#35688 — in a list cell the candidate list is open from the start. + const [isOpen, setIsOpen] = useState(!!inCell); const { t } = useFieldTranslation(); const scanOffered = useFieldScanOffered(); // Same two i18n channels RecordPickerDialog reads, so the inline dropdown @@ -1289,11 +1290,13 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro else { onChange(option.value); fillDeclaredTargets(row); + // objectstack#35688 — in a list cell a pick is the whole edit. + if (inCell) onCommit?.(); } setIsOpen(false); } }, - [multiple, value, onChange, onSelectRecord, referenceTo, normalizeId, idField, fillDeclaredTargets], + [multiple, value, onChange, onSelectRecord, referenceTo, normalizeId, idField, fillDeclaredTargets, inCell, onCommit], ); const handleRemove = (optionValue: any) => { @@ -1685,11 +1688,14 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro } else if (e.key === 'Enter') { e.preventDefault(); if (activeIndex >= 0 && activeIndex < visibleOptions.length) { + // In a list cell the grid's editor would otherwise commit again + // with the value it held before this pick (objectstack#35688). + if (inCell) e.stopPropagation(); handleSelectCandidate(visibleOptions[activeIndex]); } } }, - [visibleOptions, activeIndex, handleSelectCandidate], + [visibleOptions, activeIndex, handleSelectCandidate, inCell], ); // Scroll active item into view @@ -1904,125 +1910,9 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro ) : null; - return ( -
- {/* Selected values display — a multi-select field's chips (full mode - only; compact and single-select show the value in the trigger) */} - {multiple && selectedOptions.length > 0 && !compact && ( -
- {selectedOptions.map((opt, idx) => { - const chipLabel = opt?.label || opt?.[displayField]; - // Search-first (people) fields show avatar chips; classic lookups - // keep the plain text Badge. - if (pickerVariant === 'search') { - const avatarUrl = chipAvatarUrl(opt); - return ( - - - {avatarUrl && } - - {getPersonInitials(String(chipLabel || ''))} - - - {chipLabel} - {chipsRemovable && ( - - )} - - ); - } - return ( - - {chipLabel} - {chipsRemovable && ( - - )} - - ); - })} -
- )} - - {/* Field control: search-first inline combobox (anchored dropdown / mobile - sheet), else the classic quick-select popover. */} - {searchVariant && dataSource && referenceTo ? ( - // A single-select field's row holds the trigger and its clear control, - // as the classic row below does; a multi-select field is unchanged. -
- { - setIsPickerOpen(o); - if (!o) setPickerInitialSearch(undefined); - }} - initialSearch={pickerInitialSearch} - title={lookupField?.label || t('common.select')} - multiple={multiple} - dataSource={dataSource} - objectName={referenceTo} - displayField={displayField} - idField={idField} - subtitleFields={subtitleFields} - avatarField={avatarField} - pageSize={lookupPageSize} - value={pickerValue} - onSelect={onChange} - onSelectRecords={handlePickerSelectRecords} - lookupFilters={queryLookupFilters} - baseFilter={dependentFilter} - /> - {lookupScan} - {singleClear} -
- ) : ( -
- { - if (!dependenciesMissing) setIsOpen(o); - }} - > - - {triggerButton} - - {/* The popover never runs past the room Radix reports on the side it - opens to, and goes to the side with more room when its whole list - does not fit (Radix's default flip, kept): the search row keeps its - height and the list takes what is left (objectstack#34362). - Across, it is as wide as its trigger but never narrower than 18rem, - so an option name stays readable when the trigger is a narrow - line-item grid cell; and never wider than the room Radix reports, - so on a narrow screen it stays inside the viewport. The floor is - itself capped by that room (`min()`), because a min-width larger - than the max-width would win over it. Radix's default shift keeps - a widened panel on screen when the trigger sits at the right edge - (objectstack#34601). */} - + // The candidate panel: the popover's body, or the list cell's editor itself. + const lookupPanelBody = ( + <> {/* Search input — not offered on a target whose search resolves to no field (objectui#12966, see `searchOffered`); the options below are buttons, so the list stays reachable without it. */} @@ -2215,6 +2105,218 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro )}
)} + + ); + + // Level 2: classic table picker — search fields use the inline combobox above. + const recordPickerDialog = ( + hasDataSource && dataSource && referenceTo && pickerVariant !== 'search' && ( + + ) + ); + + // objectstack#35688 — the list cell's editor is the candidate list itself + // (recently used first, then results; a pick is the whole edit), with Clear + // while the cell holds a value. + if (inCell && !props.disabled) { + const holdsValue = multiple ? Array.isArray(value) && value.length > 0 : value != null && value !== ''; + const clear = holdsValue ? ( + + ) : null; + return ( +
+ {dependenciesMissing ? ( +

{t('lookup.selectFirst', { fields: dependsOnFieldsText })}

+ ) : searchVariant ? ( + {}} + title={lookupField?.label || t('common.select')} + multiple={multiple} + dataSource={dataSource!} + objectName={referenceTo!} + displayField={displayField} + idField={idField} + subtitleFields={subtitleFields} + avatarField={avatarField} + pageSize={lookupPageSize} + value={pickerValue} + onSelect={(next: any) => { + onChange(next); + if (!multiple) onCommit?.(); + }} + onSelectRecords={handlePickerSelectRecords} + lookupFilters={queryLookupFilters} + baseFilter={dependentFilter} + /> + ) : ( + lookupPanelBody + )} + {clear} + {recordPickerDialog} +
+ ); + } + + return ( +
+ {/* Selected values display — a multi-select field's chips (full mode + only; compact and single-select show the value in the trigger) */} + {multiple && selectedOptions.length > 0 && !compact && ( +
+ {selectedOptions.map((opt, idx) => { + const chipLabel = opt?.label || opt?.[displayField]; + // Search-first (people) fields show avatar chips; classic lookups + // keep the plain text Badge. + if (pickerVariant === 'search') { + const avatarUrl = chipAvatarUrl(opt); + return ( + + + {avatarUrl && } + + {getPersonInitials(String(chipLabel || ''))} + + + {chipLabel} + {chipsRemovable && ( + + )} + + ); + } + return ( + + {chipLabel} + {chipsRemovable && ( + + )} + + ); + })} +
+ )} + + {/* Field control: search-first inline combobox (anchored dropdown / mobile + sheet), else the classic quick-select popover. */} + {searchVariant && dataSource && referenceTo ? ( + // A single-select field's row holds the trigger and its clear control, + // as the classic row below does; a multi-select field is unchanged. +
+ { + setIsPickerOpen(o); + if (!o) setPickerInitialSearch(undefined); + }} + initialSearch={pickerInitialSearch} + title={lookupField?.label || t('common.select')} + multiple={multiple} + dataSource={dataSource} + objectName={referenceTo} + displayField={displayField} + idField={idField} + subtitleFields={subtitleFields} + avatarField={avatarField} + pageSize={lookupPageSize} + value={pickerValue} + onSelect={onChange} + onSelectRecords={handlePickerSelectRecords} + lookupFilters={queryLookupFilters} + baseFilter={dependentFilter} + /> + {lookupScan} + {singleClear} +
+ ) : ( +
+ { + if (!dependenciesMissing) setIsOpen(o); + }} + > + + {triggerButton} + + {/* The popover never runs past the room Radix reports on the side it + opens to, and goes to the side with more room when its whole list + does not fit (Radix's default flip, kept): the search row keeps its + height and the list takes what is left (objectstack#34362). + Across, it is as wide as its trigger but never narrower than 18rem, + so an option name stays readable when the trigger is a narrow + line-item grid cell; and never wider than the room Radix reports, + so on a narrow screen it stays inside the viewport. The floor is + itself capped by that room (`min()`), because a min-width larger + than the max-width would win over it. Radix's default shift keeps + a widened panel on screen when the trigger sits at the right edge + (objectstack#34601). */} + + {lookupPanelBody} @@ -2245,34 +2347,7 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro
)} - {/* Level 2: classic table picker — search fields use the inline combobox above. */} - {hasDataSource && dataSource && referenceTo && pickerVariant !== 'search' && ( - - )} + {recordPickerDialog}
); } diff --git a/ui/packages/fields/src/widgets/PeoplePicker.tsx b/ui/packages/fields/src/widgets/PeoplePicker.tsx index 957735cd241..fd735899e71 100644 --- a/ui/packages/fields/src/widgets/PeoplePicker.tsx +++ b/ui/packages/fields/src/widgets/PeoplePicker.tsx @@ -122,6 +122,12 @@ export interface PeoplePickerProps { inline?: boolean; /** The element the inline dropdown/sheet anchors to (the field trigger). */ trigger?: React.ReactNode; + /** + * Render the picker's body in place, with no container of its own: a list + * cell's editor layer is the container (objectstack#35688). Commits as + * `inline` does, and an Enter that picks a row stops there. + */ + embedded?: boolean; /** * A search term the picker opens with (e.g. a code scanned into a lookup). * Applied each time `open` turns true while it is set; the user can edit it @@ -153,6 +159,7 @@ export function PeoplePicker({ onSelect, onSelectRecords, inline = false, + embedded = false, trigger, initialSearch, }: PeoplePickerProps) { @@ -518,6 +525,9 @@ export function PeoplePicker({ } else if (e.key === 'Enter') { if (activeIndex >= 0 && activeIndex < navList.length) { e.preventDefault(); + // The list cell's editor would otherwise commit again with the + // value it held before this pick. + if (embedded) e.stopPropagation(); handleRowSelect(navList[activeIndex]); } } else if ( @@ -529,7 +539,7 @@ export function PeoplePicker({ handleRemove(getPersonId(selectedRecords[selectedRecords.length - 1], idField)); } }, - [navList, activeIndex, handleRowSelect, query.search, multiple, selectedRecords, handleRemove, idField], + [navList, activeIndex, handleRowSelect, query.search, multiple, selectedRecords, handleRemove, idField, embedded], ); // The candidate area's error: the main query's own failure, else the refusal @@ -684,6 +694,14 @@ export function PeoplePicker({ ); + if (embedded) { + return ( +
+ {body} +
+ ); + } + // Inline combobox: anchored Popover on desktop, bottom Sheet (opened from the // same trigger) on mobile. The trigger is the caller's field control. if (inline) { From e579b3763a56f8ed727db53dbccfc9cb94dfb668 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 09:35:34 +0000 Subject: [PATCH 4/9] test(fields): pin the flat typed faces, the in-cell record picker and the rating set in place Claude-Session: https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE Co-authored-by: Claude --- .../35688-in-cell-typed-lookup-rating.md | 19 ++ .../form-field-channel-census-12130.test.tsx | 21 +- .../data-table-cell-overlay-35688.test.tsx | 92 ++++++++- .../src/__tests__/inCellFaces-35688.test.tsx | 186 +++++++++++++++++- .../fields/src/widgets/LookupField.tsx | 16 +- .../fields/src/widgets/PeoplePicker.tsx | 12 +- .../fields/src/widgets/recentLookups.test.ts | 17 ++ .../fields/src/widgets/recentLookups.ts | 24 ++- ...inCellSelectMultipleRouting-35688.test.tsx | 54 ++++- 9 files changed, 404 insertions(+), 37 deletions(-) create mode 100644 .changeset/35688-in-cell-typed-lookup-rating.md diff --git a/.changeset/35688-in-cell-typed-lookup-rating.md b/.changeset/35688-in-cell-typed-lookup-rating.md new file mode 100644 index 00000000000..7ff3ab978a3 --- /dev/null +++ b/.changeset/35688-in-cell-typed-lookup-rating.md @@ -0,0 +1,19 @@ +--- +'@object-ui/components': patch +'@object-ui/fields': patch +'@object-ui/plugin-grid': patch +--- + +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 + +Clause-②: yes (widening) +Metadata-protocol: none + +In the list grid's cell editor (the layer over the cell, `inCell`): + +- 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. 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. +- 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, and Clear is offered while the cell holds a value. +- 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). +- 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. + +Forms, dialogs and the record page draw these widgets as before. No i18n key is added. diff --git a/ui/examples/schema-catalog/test/form-field-channel-census-12130.test.tsx b/ui/examples/schema-catalog/test/form-field-channel-census-12130.test.tsx index 44a81261d00..9981a2c75fd 100644 --- a/ui/examples/schema-catalog/test/form-field-channel-census-12130.test.tsx +++ b/ui/examples/schema-catalog/test/form-field-channel-census-12130.test.tsx @@ -310,19 +310,30 @@ const LEDGER: Readonly> = { why: 'RUNTIME SLOT — a host-supplied function; JSON has no function value (the objectui#6124 shape).', }, // objectstack#35688 — the list grid's cell editor (`ObjectGrid` through - // `FieldEditWidget`) sets these two; a form never does. + // `FieldEditWidget`) sets these two; a form never does. The typed inputs, + // rating and record pickers read them since S3 (objectstack#36023). inCell: { readers: [ - 'props@fields/src/widgets/ColorField.tsx', 'props@fields/src/widgets/MultiSelectField.tsx', - 'props@fields/src/widgets/TagsField.tsx', 'props@fields/src/widgets/TimeField.tsx', + 'props@fields/src/widgets/ColorField.tsx', 'props@fields/src/widgets/CurrencyField.tsx', + 'props@fields/src/widgets/EmailField.tsx', 'props@fields/src/widgets/LookupField.tsx', + 'props@fields/src/widgets/MultiSelectField.tsx', 'props@fields/src/widgets/NumberField.tsx', + 'props@fields/src/widgets/PercentField.tsx', 'props@fields/src/widgets/PhoneField.tsx', + 'props@fields/src/widgets/RatingField.tsx', 'props@fields/src/widgets/TagsField.tsx', + 'props@fields/src/widgets/TextField.tsx', 'props@fields/src/widgets/TimeField.tsx', + 'props@fields/src/widgets/UrlField.tsx', ], why: 'RUNTIME SLOT (objectstack#35688) — host plumbing: the grid cell editor asks for the in-cell face; where a ' + 'widget is drawn is the host\'s fact, not something a form document authors.', }, onCommit: { readers: [ - 'props@fields/src/widgets/ColorField.tsx', 'props@fields/src/widgets/MultiSelectField.tsx', - 'props@fields/src/widgets/TagsField.tsx', 'props@fields/src/widgets/TimeField.tsx', + 'props@fields/src/widgets/ColorField.tsx', 'props@fields/src/widgets/CurrencyField.tsx', + 'props@fields/src/widgets/EmailField.tsx', 'props@fields/src/widgets/LookupField.tsx', + 'props@fields/src/widgets/MultiSelectField.tsx', 'props@fields/src/widgets/NumberField.tsx', + 'props@fields/src/widgets/PercentField.tsx', 'props@fields/src/widgets/PhoneField.tsx', + 'props@fields/src/widgets/RatingField.tsx', 'props@fields/src/widgets/TagsField.tsx', + 'props@fields/src/widgets/TextField.tsx', 'props@fields/src/widgets/TimeField.tsx', + 'props@fields/src/widgets/UrlField.tsx', ], why: 'RUNTIME SLOT (objectstack#35688) — a host-supplied function (the grid cell editor\'s commit); JSON has no ' + 'function value (the objectui#6124 shape).', diff --git a/ui/packages/components/src/__tests__/data-table-cell-overlay-35688.test.tsx b/ui/packages/components/src/__tests__/data-table-cell-overlay-35688.test.tsx index dadcd275fcc..97d00d2cb28 100644 --- a/ui/packages/components/src/__tests__/data-table-cell-overlay-35688.test.tsx +++ b/ui/packages/components/src/__tests__/data-table-cell-overlay-35688.test.tsx @@ -63,7 +63,7 @@ afterEach(() => { } }); -function renderTable(extra: Record = {}) { +function renderTable(extra: Record = {}, selection: React.ComponentProps['value'] = {}) { const DataTable = ComponentRegistry.get('data-table')!; const onCellChange = vi.fn(); const schema = { @@ -82,7 +82,7 @@ function renderTable(extra: Record = {}) { ...extra, }; const utils = render( - + , ); @@ -147,7 +147,8 @@ describe('data-table — the editor and a cut-off cell draw on a layer over the // The utility that reads the seed survives the per-type floor, which rides an inner box. expect(layer.className).toContain('min-w-[max(var(--radix-popper-anchor-width),var(--cell-overlay-min-w,0px))]'); expect(layer.className).not.toMatch(/(^|\s)min-w-40(\s|$)/); - expect(layer.querySelector('.min-w-40')).not.toBeNull(); + // objectstack#36023 — a typed value takes no per-type floor: it starts at the cell's width. + expect(layer.querySelector('.min-w-40')).toBeNull(); fireEvent.keyDown(layer.querySelector('input')!, { key: 'Escape' }); expect(t.editorLayer()).toBeNull(); expect(t.previewLayer()).toBeNull(); @@ -191,3 +192,88 @@ describe('data-table — the editor and a cut-off cell draw on a layer over the expect(t.onCellChange).toHaveBeenCalledWith(0, 'name', 'Alpha 2', expect.anything()); }); }); + +describe('data-table — typed values edit flat in the cell; a rating is set in place (objectstack#36023)', () => { + it('the built-in text editor is the flat face, and the layer drops its padding, radius and shadow for it', () => { + const t = renderTable(); + fireEvent.click(t.cell(0, 0)); + fireEvent.keyDown(t.catcher(), { key: 'Enter' }); + const layer = t.editorLayer()!; + const input = layer.querySelector('[data-in-cell-face="input"] input[data-in-cell-input]')!; + expect(input).toHaveValue('Alpha'); + expect(input.className).toMatch(/\bborder-0\b/); + expect(input.className).toMatch(/\brounded-none\b/); + expect(input.className).not.toMatch(/(^|\s)h-10(\s|$)/); + // The layer reads the marked face (`:has()` utilities, spelled in full for Tailwind). + expect(layer.className).toContain('has-[[data-in-cell-face=input]]:p-0'); + expect(layer.className).toContain('has-[[data-in-cell-face=input]]:rounded-none'); + expect(layer.className).toContain('has-[[data-in-cell-face=input]]:border-2'); + // The form-density height skips the flat input. + expect(layer.className).toContain(':not([data-in-cell-input])]:h-8'); + }); + + function renderRating() { + const onCellChange = vi.fn(); + const t = renderTable( + { + columns: [ + { header: 'Name', accessorKey: 'name' }, + { + header: 'Score', + accessorKey: 'score', + // The stars the rating cell renderer draws, one hit target each. + cell: (value: number) => ( + {[1, 2, 3, 4, 5].map((n) => )} + ), + }, + ], + data: [{ id: '1', name: 'Alpha', score: 2 }], + onCellChange, + }, + { describeCell: (_row, key) => (key === 'score' ? { stars: 5 } : null) }, + ); + return { ...t, onCellChange }; + } + + it('a digit on the selected rating sets that many stars, at most the scale; 0 and Backspace clear', () => { + const t = renderRating(); + fireEvent.click(t.cell(0, 1)); + fireEvent.keyDown(t.catcher(), { key: '3' }); + expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', 3, expect.anything()); + fireEvent.keyDown(t.catcher(), { key: '9' }); + expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', 5, expect.anything()); + fireEvent.keyDown(t.catcher(), { key: '0' }); + expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', null, expect.anything()); + fireEvent.keyDown(t.catcher(), { key: '4' }); + fireEvent.keyDown(t.catcher(), { key: 'Backspace' }); + expect(t.onCellChange).toHaveBeenLastCalledWith(0, 'score', null, expect.anything()); + expect(t.editorLayer()).toBeNull(); + }); + + it('Enter, F2 and a double-click open no editor on a rating', () => { + const t = renderRating(); + fireEvent.click(t.cell(0, 1)); + fireEvent.keyDown(t.catcher(), { key: 'Enter' }); + fireEvent.keyDown(t.catcher(), { key: 'F2' }); + fireEvent.doubleClick(t.cell(0, 1)); + expect(t.editorLayer()).toBeNull(); + expect(t.onCellChange).not.toHaveBeenCalled(); + }); + + it('the first click on a star only selects; a click on a star of the selected cell sets it', () => { + const t = renderRating(); + const star = (n: number) => t.cell(0, 1).querySelector(`[data-rating-star="${n}"]`)!; + fireEvent.click(star(4)); + expect(t.cell(0, 1)).toHaveAttribute('data-selected-cell'); + expect(t.onCellChange).not.toHaveBeenCalled(); + fireEvent.click(star(4)); + expect(t.onCellChange).toHaveBeenCalledWith(0, 'score', 4, expect.anything()); + }); + + it('CONTROL: without the stars fact a digit opens the editor as typing does', () => { + const t = renderTable(); + fireEvent.click(t.cell(0, 0)); + fireEvent.keyDown(t.catcher(), { key: '3' }); + expect(t.onCellChange).not.toHaveBeenCalled(); + }); +}); diff --git a/ui/packages/fields/src/__tests__/inCellFaces-35688.test.tsx b/ui/packages/fields/src/__tests__/inCellFaces-35688.test.tsx index 9c545605f6f..1d87046ea80 100644 --- a/ui/packages/fields/src/__tests__/inCellFaces-35688.test.tsx +++ b/ui/packages/fields/src/__tests__/inCellFaces-35688.test.tsx @@ -7,10 +7,11 @@ */ /** - * objectstack#35688 (slice S2) — the faces the option, tags, date, time and - * colour widgets draw in the list grid's cell editor (`inCell`), and the - * `onCommit` call that ends an edit on a pick. Without `inCell` each widget - * keeps its form face. + * objectstack#35688 (slices S2 and S3) — the faces the widgets draw in the + * list grid's cell editor (`inCell`), and the `onCommit` call that ends an + * edit on a pick: options, tags, dates, time and colour (S2); the typed + * inputs, rating and record pickers (S3, with objectstack#36023's flat typed + * input). Without `inCell` each widget keeps its form face. */ import React from 'react'; @@ -23,6 +24,15 @@ import { ColorField } from '../widgets/ColorField'; import { TimeField } from '../widgets/TimeField'; import { DatePickerField, DateTimePickerField } from '../widgets/date-picker/DatePickerField'; import { FieldEditWidget } from '../FieldEditWidget'; +import { TextField } from '../widgets/TextField'; +import { EmailField } from '../widgets/EmailField'; +import { PhoneField } from '../widgets/PhoneField'; +import { UrlField } from '../widgets/UrlField'; +import { NumberField } from '../widgets/NumberField'; +import { CurrencyField } from '../widgets/CurrencyField'; +import { PercentField } from '../widgets/PercentField'; +import { RatingField } from '../widgets/RatingField'; +import { LookupField } from '../widgets/LookupField'; afterEach(() => cleanup()); @@ -280,3 +290,171 @@ describe('FieldEditWidget hands the cell face on (objectstack#35688)', () => { expect(forwarded.onCommit).toBe(onCommit); }); }); + +/** The typed-input face: one flat input, marked for the layer, inside a marked box. */ +function inCellInput(container: HTMLElement): HTMLInputElement { + const face = container.querySelector('[data-in-cell-face="input"]'); + expect(face).not.toBeNull(); + const input = face!.querySelector('input[data-in-cell-input]') as HTMLInputElement | null; + expect(input).not.toBeNull(); + // No border, radius or fill of its own: the layer's frame is the only line. + expect(input!.className).toContain('border-0'); + expect(input!.className).toContain('bg-transparent'); + expect(input!.className).not.toContain('rounded-md'); + return input!; +} + +describe('in-cell typed inputs are the cell itself (objectstack#36023)', () => { + it('text: a flat input whose sizing copy follows the text, so the layer grows to the right', () => { + const onChange = vi.fn(); + const { container } = render(); + const input = inCellInput(container); + expect(input.type).toBe('text'); + expect(input.value).toBe('Acme'); + const sizer = input.previousElementSibling as HTMLElement; + expect(sizer.getAttribute('aria-hidden')).toBe('true'); + expect(sizer.textContent).toBe('Acme'); + fireEvent.change(input, { target: { value: 'Acme Corporation International' } }); + expect(onChange).toHaveBeenCalledWith('Acme Corporation International'); + }); + + it('email, phone and url take the same face with their input types', () => { + const cases: Array<[React.ReactElement, string]> = [ + [ {}} inCell />, 'email'], + [ {}} inCell />, 'tel'], + [ {}} inCell />, 'url'], + ]; + for (const [element, type] of cases) { + const { container, unmount } = render(element); + expect(inCellInput(container).type).toBe(type); + unmount(); + } + }); + + it('number: the raw number, right-aligned', () => { + const onChange = vi.fn(); + const { container } = render(); + const input = inCellInput(container); + expect(input.type).toBe('number'); + expect(input.value).toBe('1234.5'); + expect(input.className).toContain('text-right'); + fireEvent.change(input, { target: { value: '12' } }); + expect(onChange).toHaveBeenCalledWith(12); + }); + + it('currency: the currency code, then the raw amount right-aligned (34,500.50 shows whole)', () => { + const { container } = render( + {}} inCell />, + ); + const input = inCellInput(container); + expect(input.value).toBe('34500.5'); + expect(input.className).toContain('text-right'); + expect(container.querySelector('[data-in-cell-face="input"]')!.textContent).toContain('USD'); + }); + + it('percent: the points without a slider, and no binary noise from the fraction', () => { + const { container } = render( {}} inCell />); + const input = inCellInput(container); + expect(input.value).toBe('7'); + expect(screen.queryByTestId('percent-slider')).toBeNull(); + expect(container.textContent).toContain('%'); + }); + + it('CONTROL: without inCell the text, number and percent widgets keep their form faces', () => { + const { container } = render( + <> + {}} /> + {}} /> + {}} /> + , + ); + expect(container.querySelector('[data-in-cell-face]')).toBeNull(); + expect(screen.getByTestId('percent-slider')).toBeTruthy(); + }); +}); + +describe('in-cell rating (objectstack#35688)', () => { + it('draws the stars at the cell size and no "n / max" caption; a click picks', () => { + const onChange = vi.fn(); + const { container } = render(); + expect(container.textContent).not.toContain('2 / 5'); + const stars = container.querySelectorAll('button'); + expect(stars).toHaveLength(5); + expect(stars[0].querySelector('svg')!.getAttribute('class')).toContain('w-3.5'); + fireEvent.click(stars[3]); + expect(onChange).toHaveBeenCalledWith(4); + }); + + it('CONTROL: the form face keeps its caption', () => { + const { container } = render( {}} />); + expect(container.textContent).toContain('2 / 5'); + }); +}); + +const PRIORITY = { + type: 'lookup', + name: 'priority', + label: 'Priority', + reference: 'priorities', + options: [ + { label: 'High', value: 'high' }, + { label: 'Normal', value: 'normal' }, + ], +} as never; + +describe('in-cell record picker (objectstack#35688)', () => { + it('shows the searchable candidate list at once, no trigger to press; a click picks and ends the edit', () => { + const calls: string[] = []; + render( + calls.push(`change:${String(v)}`)} + onCommit={() => calls.push('commit')} + inCell + />, + ); + expect(screen.queryByRole('button', { name: /select/i })).toBeNull(); + const panel = screen.getByTestId('lookup-in-cell'); + expect(within(panel).getByRole('listbox')).toBeTruthy(); + fireEvent.click(within(panel).getByText('Normal')); + // The value is handed over first, then the edit ends. + expect(calls).toEqual(['change:normal', 'commit']); + }); + + it('Enter on the active candidate picks it and does not reach the grid', () => { + const onGridKey = vi.fn(); + const onChange = vi.fn(); + render( + + {}} inCell /> + , + ); + const box = screen.getByRole('combobox'); + fireEvent.keyDown(box, { key: 'ArrowDown' }); + fireEvent.keyDown(box, { key: 'Enter' }); + expect(onChange).toHaveBeenCalledWith('high'); + expect(onGridKey).not.toHaveBeenCalledWith('Enter'); + }); + + it('Clear is offered while the cell holds a value, and clearing ends the edit', () => { + const calls: string[] = []; + render( + calls.push(`change:${String(v)}`)} + onCommit={() => calls.push('commit')} + inCell + />, + ); + fireEvent.click(screen.getByTestId('lookup-in-cell-clear')); + expect(calls).toEqual(['change:null', 'commit']); + }); + + it('CONTROL: without inCell the trigger stays and the list is closed', () => { + render( {}} />); + expect(screen.queryByTestId('lookup-in-cell')).toBeNull(); + expect(screen.queryByRole('listbox')).toBeNull(); + }); +}); diff --git a/ui/packages/fields/src/widgets/LookupField.tsx b/ui/packages/fields/src/widgets/LookupField.tsx index 3414c2394b2..0c12b9f0ff5 100644 --- a/ui/packages/fields/src/widgets/LookupField.tsx +++ b/ui/packages/fields/src/widgets/LookupField.tsx @@ -1281,11 +1281,11 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro if (isSelected) { onChange(currentValues.filter((v: any) => v !== option.value)); } else { - if (referenceTo) pushRecentLookupId(referenceTo, option.value); + if (referenceTo) pushRecentLookupId(referenceTo, option.value, perms.userId); onChange([...currentValues, option.value]); } } else { - if (referenceTo) pushRecentLookupId(referenceTo, option.value); + if (referenceTo) pushRecentLookupId(referenceTo, option.value, perms.userId); if (onSelectRecord) onSelectRecord(option); else { onChange(option.value); @@ -1296,7 +1296,7 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro setIsOpen(false); } }, - [multiple, value, onChange, onSelectRecord, referenceTo, normalizeId, idField, fillDeclaredTargets, inCell, onCommit], + [multiple, value, onChange, onSelectRecord, referenceTo, normalizeId, idField, fillDeclaredTargets, inCell, onCommit, perms.userId], ); const handleRemove = (optionValue: any) => { @@ -1315,7 +1315,7 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro const handlePickerSelectRecords = useCallback( (records: Record[]) => { if (referenceTo) { - records.forEach((r) => pushRecentLookupId(referenceTo, recordValue(r, idField) as string | number | undefined)); + records.forEach((r) => pushRecentLookupId(referenceTo, recordValue(r, idField) as string | number | undefined, perms.userId)); } // A single pick from a Level-2 picker commits its id through `onSelect` // (`onChange`) just before this, so the declared targets fill here, from @@ -1323,7 +1323,7 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro if (!multiple && records.length === 1) fillDeclaredTargets(records[0]); setPickedRecords(records); }, - [idField, referenceTo, multiple, fillDeclaredTargets], + [idField, referenceTo, multiple, fillDeclaredTargets, perms.userId], ); /** @@ -1347,7 +1347,7 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro return; } const row = records[0]; - if (referenceTo) pushRecentLookupId(referenceTo, recordValue(row, idField) as string | number | undefined); + if (referenceTo) pushRecentLookupId(referenceTo, recordValue(row, idField) as string | number | undefined, perms.userId); setPickedRecords(records); onSelectRecord(recordToOption(row, declaredDisplayField, idField, effectiveDescriptionField, refObjectSchema, perms, referenceTo)); }, @@ -1395,7 +1395,7 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro if (!isOpen || !hasDataSource || !dataSource || !referenceTo || searchQuery) return; if (dependenciesMissing) { setRecentRows([]); return; } if (recordReadsPending) return; - const ids = getRecentLookupIds(referenceTo); + const ids = getRecentLookupIds(referenceTo, perms.userId); if (!ids.length) { setRecentRows([]); return; } let cancelled = false; (async () => { @@ -1425,7 +1425,7 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro })(); return () => { cancelled = true; }; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [isOpen, hasDataSource, referenceTo, searchQuery, dependenciesMissing, recordReadsPending, popoverFilter, idField, candidateExpandKey]); + }, [isOpen, hasDataSource, referenceTo, searchQuery, dependenciesMissing, recordReadsPending, popoverFilter, idField, candidateExpandKey, perms.userId]); const recentOptions = useMemo( () => recentRows.map((r) => diff --git a/ui/packages/fields/src/widgets/PeoplePicker.tsx b/ui/packages/fields/src/widgets/PeoplePicker.tsx index fd735899e71..c315561cbd8 100644 --- a/ui/packages/fields/src/widgets/PeoplePicker.tsx +++ b/ui/packages/fields/src/widgets/PeoplePicker.tsx @@ -270,8 +270,8 @@ export function PeoplePicker({ // Recent ids captured once per open. const recentIds = useMemo( - () => (open ? getRecentLookupIds(objectName) : []), - [open, objectName], + () => (open ? getRecentLookupIds(objectName, perms.userId) : []), + [open, objectName, perms.userId], ); // The current value's ids, for hydrating the SelectionTray on edit. @@ -390,10 +390,10 @@ export function PeoplePicker({ (ids: any[], records: any[]) => { onSelect(multiple ? ids : (ids[0] ?? null)); onSelectRecords?.(records); - ids.forEach(id => pushRecentLookupId(objectName, id)); + ids.forEach(id => pushRecentLookupId(objectName, id, perms.userId)); onOpenChange(false); }, - [multiple, objectName, onSelect, onSelectRecords, onOpenChange], + [multiple, objectName, onSelect, onSelectRecords, onOpenChange, perms.userId], ); // Inline mode has no confirm step — push the value out on every change. @@ -421,11 +421,11 @@ export function PeoplePicker({ // Inline: commit live (chips live in the field), stay open for more. // Modal: stage in the tray until Confirm. if (inline) { - if (!exists) pushRecentLookupId(objectName, id); + if (!exists) pushRecentLookupId(objectName, id, perms.userId); commitLive(next); } }, - [multiple, idField, commit, selectedRecords, inline, objectName, commitLive], + [multiple, idField, commit, selectedRecords, inline, objectName, commitLive, perms.userId], ); const handleRemove = useCallback( diff --git a/ui/packages/fields/src/widgets/recentLookups.test.ts b/ui/packages/fields/src/widgets/recentLookups.test.ts index 80d9376f822..5770ee68d46 100644 --- a/ui/packages/fields/src/widgets/recentLookups.test.ts +++ b/ui/packages/fields/src/widgets/recentLookups.test.ts @@ -43,3 +43,20 @@ describe('recentLookups', () => { expect(getRecentLookupIds('acc')).toEqual([]); }); }); + +describe('recentLookups per user (objectstack#35688)', () => { + beforeEach(() => localStorage.clear()); + + it('keeps one ring per user, so two accounts in one browser never share picks', () => { + pushRecentLookupId('acc', 'a', 'u1'); + pushRecentLookupId('acc', 'b', 'u2'); + expect(getRecentLookupIds('acc', 'u1')).toEqual(['a']); + expect(getRecentLookupIds('acc', 'u2')).toEqual(['b']); + }); + + it('without a known user the ring is the object\'s alone, as before', () => { + pushRecentLookupId('acc', 'a'); + expect(getRecentLookupIds('acc')).toEqual(['a']); + expect(getRecentLookupIds('acc', 'u1')).toEqual([]); + }); +}); diff --git a/ui/packages/fields/src/widgets/recentLookups.ts b/ui/packages/fields/src/widgets/recentLookups.ts index 7272a75bfd8..31a3445d38c 100644 --- a/ui/packages/fields/src/widgets/recentLookups.ts +++ b/ui/packages/fields/src/widgets/recentLookups.ts @@ -9,6 +9,16 @@ */ const KEY_PREFIX = 'objectui:lookup:recent:'; + +/** + * The ring's storage key: per user as well as per object, so two accounts + * signed in one after the other in the same browser never see each other's + * picks. Without a known user (no permission provider) the key is the + * object's alone, as it always was. + */ +function keyOf(objectName: string, userId: string | null | undefined): string { + return userId ? `${KEY_PREFIX}${userId}:${objectName}` : KEY_PREFIX + objectName; +} const MAX_RECENT = 5; function storage(): Storage | null { @@ -20,12 +30,12 @@ function storage(): Storage | null { } } -/** Most-recent-first list of record ids previously chosen for `objectName`. */ -export function getRecentLookupIds(objectName: string): Array { +/** Most-recent-first list of record ids `userId` previously chose for `objectName`. */ +export function getRecentLookupIds(objectName: string, userId?: string | null): Array { const s = storage(); if (!objectName || !s) return []; try { - const raw = s.getItem(KEY_PREFIX + objectName); + const raw = s.getItem(keyOf(objectName, userId)); if (!raw) return []; const arr = JSON.parse(raw); return Array.isArray(arr) ? arr.slice(0, MAX_RECENT) : []; @@ -34,13 +44,13 @@ export function getRecentLookupIds(objectName: string): Array { } } -/** Record that `id` was just chosen for `objectName` (moves it to the front). */ -export function pushRecentLookupId(objectName: string, id: string | number | null | undefined): void { +/** Record that `userId` just chose `id` for `objectName` (moves it to the front). */ +export function pushRecentLookupId(objectName: string, id: string | number | null | undefined, userId?: string | null): void { const s = storage(); if (!objectName || id === null || id === undefined || id === '' || !s) return; try { - const next = [id, ...getRecentLookupIds(objectName).filter((x) => x !== id)].slice(0, MAX_RECENT); - s.setItem(KEY_PREFIX + objectName, JSON.stringify(next)); + const next = [id, ...getRecentLookupIds(objectName, userId).filter((x) => x !== id)].slice(0, MAX_RECENT); + s.setItem(keyOf(objectName, userId), JSON.stringify(next)); } catch { // Ignore quota / serialization failures — recents are best-effort. } diff --git a/ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx b/ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx index 8a5d6f22f59..1fd75333cfc 100644 --- a/ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx +++ b/ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx @@ -12,6 +12,9 @@ * `multiple` draws the check list in the cell editor, and each check only * stages. The edit is saved when the user moves on, as for `multiselect`. * A single `select` still saves on the pick (CONTROL). + * + * S3: a lookup cell opens its candidate list in place and a pick ends the + * edit; on a select-first grid a rating is set by a digit, with no editor. */ import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest'; import { render, screen, waitFor, fireEvent, cleanup } from '@testing-library/react'; @@ -59,10 +62,14 @@ const COLORS = [ function makeDataSource() { const store: Record = { - r1: { id: 'r1', title: 'Design system', priority: 'high', colors: ['blue'] }, + r1: { id: 'r1', title: 'Design system', priority: 'high', colors: ['blue'], score: 2, tier: null }, }; return { - find: vi.fn(async () => { + find: vi.fn(async (objectName: string) => { + if (objectName === 'tier_35688') { + const tiers = [{ id: 'gold', name: 'Gold' }, { id: 'silver', name: 'Silver' }]; + return { data: tiers, total: tiers.length, hasMore: false, pageSize: 50 }; + } const data = Object.values(store).map((r) => ({ ...r })); return { data, total: data.length, hasMore: false, pageSize: 50 }; }), @@ -85,12 +92,22 @@ function makeDataSource() { ], }, colors: { type: 'select', multiple: true, label: 'Colors', options: COLORS }, + score: { type: 'rating', label: 'Score', max: 5 }, + tier: { + type: 'lookup', + label: 'Tier', + reference: 'tier_35688', + options: [ + { label: 'Gold', value: 'gold' }, + { label: 'Silver', value: 'silver' }, + ], + }, }, }), } as any; } -function renderGrid() { +function renderGrid(cellSelection = false) { const ds = makeDataSource(); const schema: any = { type: 'object-grid', @@ -101,6 +118,8 @@ function renderGrid() { { field: 'title', label: 'Title', type: 'text' }, { field: 'priority', label: 'Priority', type: 'select' }, { field: 'colors', label: 'Colors', type: 'select' }, + { field: 'score', label: 'Score', type: 'rating' }, + { field: 'tier', label: 'Tier', type: 'lookup' }, ], pagination: { pageSize: 50 }, }; @@ -109,7 +128,7 @@ function renderGrid() {
- +
, @@ -165,3 +184,30 @@ describe('ObjectGrid cell editor: a select declared multiple (objectstack#35688 expect(cellUnder(container, 'Priority').textContent).toContain('Low'); }); }); + +describe('ObjectGrid cell editor: lookups and ratings (objectstack#35688 S3)', () => { + it('a lookup cell opens its candidate list in place; a pick ends the edit', async () => { + const { container } = renderGrid(); + await waitFor(() => expect(screen.getByText('Design system')).toBeInTheDocument()); + + fireEvent.click(cellUnder(container, 'Tier')); + await waitFor(() => expect(screen.getByTestId('lookup-in-cell')).toBeInTheDocument()); + fireEvent.click(await screen.findByText('Silver')); + + await waitFor(() => expect(screen.queryByTestId('lookup-in-cell')).toBeNull()); + await waitFor(() => expect(screen.getByText(/1 row modified/)).toBeInTheDocument()); + }); + + it('on a select-first grid a digit sets the rating and opens no editor', async () => { + const { container, ds } = renderGrid(true); + await waitFor(() => expect(screen.getByText('Design system')).toBeInTheDocument()); + + fireEvent.click(cellUnder(container, 'Score')); + const catcher = container.querySelector('[data-slot="cell-type-catcher"]')!; + fireEvent.keyDown(catcher, { key: 'Enter' }); + expect(container.querySelector('[data-slot="cell-editor-overlay"]')).toBeNull(); + fireEvent.keyDown(catcher, { key: '4' }); + await waitFor(() => expect(ds.update).toHaveBeenCalled()); + expect(ds.update.mock.calls[0].slice(0, 3)).toEqual([OBJECT, 'r1', { score: 4 }]); + }); +}); From 6a5a9b4aa66df199ba28065309d5d75a3a3781fd Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 10:33:21 +0000 Subject: [PATCH 5/9] fix(fields): in-cell lookup keeps Browse all; grid picker tests read the in-cell list (#35688) The cell's lookup editor is now the candidate list itself, so the three grid picker suites (#7154, #7165, #7166) open the cell and read the list instead of pressing a trigger first. Their claims stay: dependsOn gates and scopes, multiple accumulates, allowCreate, lookupPageSize via Browse all, and the descriptionField / lookupColumns / lookupFilters keys. Browse all (the full record picker) was beside the form trigger only; the in-cell face now carries it too, gated like the list. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE --- .../fields/src/widgets/LookupField.tsx | 20 +++++- .../gridDependentValues-7165.test.tsx | 70 ++++++++++++------- .../__tests__/lookupPickerKeys-7154.test.tsx | 65 +++++++++++------ .../relationalMetaCopySet-7166.test.tsx | 46 ++++++++---- 4 files changed, 137 insertions(+), 64 deletions(-) diff --git a/ui/packages/fields/src/widgets/LookupField.tsx b/ui/packages/fields/src/widgets/LookupField.tsx index 0c12b9f0ff5..5fc0443a25b 100644 --- a/ui/packages/fields/src/widgets/LookupField.tsx +++ b/ui/packages/fields/src/widgets/LookupField.tsx @@ -2160,10 +2160,27 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro {t('lookup.clear')} ) : null; + // The full record picker, as the "Browse All" button beside the form's + // trigger opens it — classic lookups only, gated like the list (#2215). + const browseAll = hasDataSource && pickerVariant !== 'search' ? ( + + ) : null; return (
{dependenciesMissing ? ( -

{t('lookup.selectFirst', { fields: dependsOnFieldsText })}

+

+ {t('lookup.selectFirst', { fields: dependsOnFieldsText })} +

) : searchVariant ? ( diff --git a/ui/packages/plugin-grid/src/__tests__/gridDependentValues-7165.test.tsx b/ui/packages/plugin-grid/src/__tests__/gridDependentValues-7165.test.tsx index f7e963fed03..a636dd9012b 100644 --- a/ui/packages/plugin-grid/src/__tests__/gridDependentValues-7165.test.tsx +++ b/ui/packages/plugin-grid/src/__tests__/gridDependentValues-7165.test.tsx @@ -175,16 +175,34 @@ function cellAt(container: HTMLElement, rowIndex: number, index: number): HTMLEl return tds[index]; } -/** Single-click into a cell and hand back the widget's own trigger button. */ -async function openEditor(cell: HTMLElement): Promise { +/** + * Single-click into a cell and hand back the lookup's in-cell face. Since + * objectstack#35688 S3 the cell's editor IS the candidate list (no trigger + * button to press first): the list is open, the gate shows as a hint in its + * place, and "Browse all" sits under it. + */ +async function openEditor(cell: HTMLElement): Promise { fireEvent.click(cell); return await waitFor(() => { - const btn = cell.querySelector('button'); - expect(btn).toBeTruthy(); - return btn as HTMLButtonElement; + const panel = cell.querySelector('[data-testid="lookup-in-cell"]'); + expect(panel).toBeTruthy(); + return panel as HTMLElement; }); } +/** + * Esc where the user presses it: on whatever holds focus inside the cell's + * editor (the list's search box), so it reaches the grid's own key handling. + */ +function pressEscape(): void { + fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); +} + +/** The in-cell face's gate hint, or null when the list is usable. */ +function gateOf(panel: HTMLElement): HTMLElement | null { + return panel.querySelector('[data-testid="lookup-in-cell-gated"]'); +} + const ROW_NORTH = { id: 't1', title: 'Task one', region: 'north', owner: null, regional_owner: null }; const ROW_NO_REGION = { id: 't2', title: 'Task two', region: '', owner: null, regional_owner: null }; @@ -198,19 +216,19 @@ describe('objectui#7165 — the grid feeds the inline editor its row as dependen // CONTROL — same reference, same records, no `dependsOn`. Load-bearing in // BOTH directions: if this column were broken the test below would be // measuring a dead picker path rather than the declared key. - const controlTrigger = await openEditor(cellAt(container, 0, 2)); - expect(controlTrigger.getAttribute('data-testid')).toBe('lookup-trigger-owner'); - expect(controlTrigger.disabled).toBe(false); - fireEvent.keyDown(document.body, { key: 'Escape' }); + const controlPanel = await openEditor(cellAt(container, 0, 2)); + expect(gateOf(controlPanel)).toBeNull(); + await waitFor(() => expect(within(controlPanel).getByText('Person 01')).toBeInTheDocument()); + pressEscape(); // ⭐ THE CARD'S MEASUREMENT, INVERTED. On `51449a043` and on `899730e0a` // before this change, this trigger was `lookup-trigger-gated`, `disabled`, // reading "Select region first" — with the row already carrying - // `region: 'north'`. It is now an ordinary named, enabled trigger. - const dependentTrigger = await openEditor(cellAt(container, 0, 3)); - expect(dependentTrigger.getAttribute('data-testid')).toBe('lookup-trigger-regional_owner'); - expect(dependentTrigger.disabled).toBe(false); - expect(dependentTrigger.textContent).not.toMatch(/select region first/i); + // `region: 'north'`. It is now an ordinary usable list (since + // objectstack#35688 S3 the in-cell face is the list itself). + const dependentPanel = await openEditor(cellAt(container, 0, 3)); + expect(gateOf(dependentPanel)).toBeNull(); + expect(dependentPanel.textContent).not.toMatch(/select region first/i); // The browse-all button shared the gate (PR objectui#2216) and is live too. expect(within(cellAt(container, 0, 3)).getByTestId('browse-all-records')).not.toBeDisabled(); }); @@ -225,18 +243,18 @@ describe('objectui#7165 — the grid feeds the inline editor its row as dependen // `$filter`, so only the six north people are candidates. This is what // proves the fix supplied a CORRECT record and not merely a non-empty one // — an unscoped picker would list Person 07. - fireEvent.click(await openEditor(cellAt(container, 0, 3))); + await openEditor(cellAt(container, 0, 3)); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); expect(screen.queryByText('Person 07')).not.toBeInTheDocument(); expect(ds.refQueries.some((q: any) => q?.$filter?.region === 'north')).toBe(true); - fireEvent.keyDown(document.body, { key: 'Escape' }); + pressEscape(); await waitFor(() => expect(screen.queryByText('Person 01')).not.toBeInTheDocument()); // CONTROL — the sibling column declares no `dependsOn`, so the SAME // reference over the SAME records is unfiltered and a south person is // offered. Without this, "Person 07 is absent" could just mean the picker // never loaded. - fireEvent.click(await openEditor(cellAt(container, 0, 2))); + await openEditor(cellAt(container, 0, 2)); await waitFor(() => expect(screen.getByText('Person 07')).toBeInTheDocument()); }); @@ -250,16 +268,16 @@ describe('objectui#7165 — the grid feeds the inline editor its row as dependen const { container } = renderGrid(ds, rows); await waitFor(() => expect(screen.getByText('Task two')).toBeInTheDocument()); - const gatedTrigger = await openEditor(cellAt(container, 1, 3)); - expect(gatedTrigger.getAttribute('data-testid')).toBe('lookup-trigger-gated'); - expect(gatedTrigger.disabled).toBe(true); - expect(gatedTrigger.textContent).toMatch(/region/i); - fireEvent.keyDown(document.body, { key: 'Escape' }); + const gatedPanel = await openEditor(cellAt(container, 1, 3)); + expect(gateOf(gatedPanel)?.textContent).toMatch(/region/i); + expect(within(gatedPanel).getByTestId('browse-all-records')).toBeDisabled(); + expect(within(gatedPanel).queryAllByRole('option')).toHaveLength(0); + pressEscape(); // CONTROL — the row above, same render, same column: filled parent, open. - const openTrigger = await openEditor(cellAt(container, 0, 3)); - expect(openTrigger.getAttribute('data-testid')).toBe('lookup-trigger-regional_owner'); - expect(openTrigger.disabled).toBe(false); + const openPanel = await openEditor(cellAt(container, 0, 3)); + expect(gateOf(openPanel)).toBeNull(); + expect(within(openPanel).getByTestId('browse-all-records')).not.toBeDisabled(); }); it('4 — ⭐ objectui#7188: a STAGED parent re-scopes the child before anything is saved', async () => { @@ -291,7 +309,7 @@ describe('objectui#7165 — the grid feeds the inline editor its row as dependen // Open the child. Clicking another cell moves the edit; the staged value // stays in `pendingChanges`. - fireEvent.click(await openEditor(cellAt(container, 0, 3))); + await openEditor(cellAt(container, 0, 3)); await waitFor(() => expect(screen.getByText('Person 07')).toBeInTheDocument()); // ⭐ PROOF THE STAGING LANDED AND NOTHING WAS SAVED. Without the first half diff --git a/ui/packages/plugin-grid/src/__tests__/lookupPickerKeys-7154.test.tsx b/ui/packages/plugin-grid/src/__tests__/lookupPickerKeys-7154.test.tsx index 563697eb3ce..5014d3d6188 100644 --- a/ui/packages/plugin-grid/src/__tests__/lookupPickerKeys-7154.test.tsx +++ b/ui/packages/plugin-grid/src/__tests__/lookupPickerKeys-7154.test.tsx @@ -192,16 +192,34 @@ function cellAt(container: HTMLElement, index: number): HTMLElement { return tds[index]; } -/** Single-click into a cell and hand back the widget's own trigger button. */ -async function openEditor(cell: HTMLElement): Promise { +/** + * Single-click into a cell and hand back the lookup's in-cell face. Since + * objectstack#35688 S3 the cell's editor IS the candidate list (no trigger + * button to press first): the list is open, the gate shows as a hint in its + * place, and "Browse all" sits under it. + */ +async function openEditor(cell: HTMLElement): Promise { fireEvent.click(cell); return await waitFor(() => { - const btn = cell.querySelector('button'); - expect(btn).toBeTruthy(); - return btn as HTMLButtonElement; + const panel = cell.querySelector('[data-testid="lookup-in-cell"]'); + expect(panel).toBeTruthy(); + return panel as HTMLElement; }); } +/** + * Esc where the user presses it: on whatever holds focus inside the cell's + * editor (the list's search box), so it reaches the grid's own key handling. + */ +function pressEscape(): void { + fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); +} + +/** The in-cell face's gate hint, or null when the list is usable. */ +function gateOf(panel: HTMLElement): HTMLElement | null { + return panel.querySelector('[data-testid="lookup-in-cell-gated"]'); +} + describe('objectui#7154 — the four picker keys reach the grid’s inline picker off the field def', () => { it('none of the four is on the relational copy set (the premise this file re-measures)', () => { // Control: the copy set is populated and holds the key objectui#6875 added, @@ -234,20 +252,23 @@ describe('objectui#7154 — the four picker keys reach the grid’s inline picke // Declared `multiple: true` — both picks land, the popover stays open. const multiCell = cellAt(container, 1); - fireEvent.click(await openEditor(multiCell)); - fireEvent.click(await waitFor(() => screen.getByText('Person 01'))); - fireEvent.click(await waitFor(() => screen.getByText('Person 02'))); + const multiPanel = await openEditor(multiCell); + fireEvent.click(await waitFor(() => within(multiPanel).getByText('Person 01'))); + fireEvent.click(await waitFor(() => within(multiPanel).getByText('Person 02'))); await waitFor(() => { - expect(multiCell.textContent).toMatch(/2 selected/); + const picked = Array.from(multiPanel.querySelectorAll('[role="option"][aria-selected="true"]')).map((o) => o.getAttribute('title')); + expect(picked).toEqual(['Person 01', 'Person 02']); }); // CONTROL — same reference, same records, no `multiple`: the second pick // REPLACES the first and the compact trigger shows that one record. const singleCell = cellAt(container, 2); - fireEvent.click(await openEditor(singleCell)); - fireEvent.click(await waitFor(() => screen.getByText('Person 01'))); - fireEvent.click(await openEditor(singleCell)); - fireEvent.click(await waitFor(() => screen.getByText('Person 02'))); + const firstPanel = await openEditor(singleCell); + fireEvent.click(await waitFor(() => within(firstPanel).getByText('Person 01'))); + await waitFor(() => expect(singleCell.querySelector('[data-testid="lookup-in-cell"]')).toBeNull()); + const secondPanel = await openEditor(singleCell); + fireEvent.click(await waitFor(() => within(secondPanel).getByText('Person 02'))); + await waitFor(() => expect(singleCell.querySelector('[data-testid="lookup-in-cell"]')).toBeNull()); await waitFor(() => { expect(within(singleCell).getByText('Person 02')).toBeInTheDocument(); }); @@ -273,15 +294,15 @@ describe('objectui#7154 — the four picker keys reach the grid’s inline picke // CONTROL — nothing declared. `os_7154_person` is a user-facing reference, // so inline quick-create is on by default and the entry renders. const defaultCell = cellAt(container, 1); - fireEvent.click(await openEditor(defaultCell)); + await openEditor(defaultCell); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); expect(screen.getByText('Create new')).toBeInTheDocument(); - fireEvent.keyDown(document.body, { key: 'Escape' }); + pressEscape(); await waitFor(() => expect(screen.queryByText('Create new')).not.toBeInTheDocument()); // Declared `allowCreate: false` — the author's opt-out is honoured. const optedOutCell = cellAt(container, 2); - fireEvent.click(await openEditor(optedOutCell)); + await openEditor(optedOutCell); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); expect(screen.queryByText('Create new')).not.toBeInTheDocument(); }); @@ -347,9 +368,9 @@ describe('objectui#7154 — the four picker keys reach the grid’s inline picke await waitFor(() => expect(screen.getByText('Task one')).toBeInTheDocument()); // CONTROL — no `dependsOn`: an ordinary, usable trigger. - const plainTrigger = await openEditor(cellAt(container, 2)); - expect(plainTrigger.getAttribute('data-testid')).toBe('lookup-trigger-owner'); - expect(plainTrigger.disabled).toBe(false); + const plainPanel = await openEditor(cellAt(container, 2)); + expect(gateOf(plainPanel)).toBeNull(); + pressEscape(); // Declared `dependsOn: ['region']`. ⭐ UPDATED BY objectui#7165 — this used // to assert `lookup-trigger-gated` / `disabled === true`, which pinned the @@ -362,16 +383,14 @@ describe('objectui#7154 — the four picker keys reach the grid’s inline picke // The key still ARRIVES off the field def — which is this file's whole // claim — and the proof is no longer the gate but the SCOPING asserted // below: an unscoped picker would list all twelve people. - const dependentTrigger = await openEditor(cellAt(container, 3)); - expect(dependentTrigger.getAttribute('data-testid')).toBe('lookup-trigger-regional_owner'); - expect(dependentTrigger.disabled).toBe(false); + const dependentPanel = await openEditor(cellAt(container, 3)); + expect(gateOf(dependentPanel)).toBeNull(); // The browse-all button next to it is live too (it shared the gate before). expect(within(cellAt(container, 3)).getByTestId('browse-all-records')).not.toBeDisabled(); // The `dependsOn` chain reaches the query as a hard `$filter` (PR // objectui#2216's half 2, which was always live here — it just never had // an input). `region: 'north'` → only the six north people are offered. - fireEvent.click(dependentTrigger); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); expect(screen.queryByText('Person 07')).not.toBeInTheDocument(); expect(ds.refQueries.some((q: any) => q?.$filter?.region === 'north')).toBe(true); diff --git a/ui/packages/plugin-grid/src/__tests__/relationalMetaCopySet-7166.test.tsx b/ui/packages/plugin-grid/src/__tests__/relationalMetaCopySet-7166.test.tsx index 7005384cb2f..3b7f9ce43ad 100644 --- a/ui/packages/plugin-grid/src/__tests__/relationalMetaCopySet-7166.test.tsx +++ b/ui/packages/plugin-grid/src/__tests__/relationalMetaCopySet-7166.test.tsx @@ -159,16 +159,34 @@ function cellAt(container: HTMLElement, index: number): HTMLElement { return tds[index]; } -/** Single-click into a cell and hand back the widget's own trigger button. */ -async function openEditor(cell: HTMLElement): Promise { +/** + * Single-click into a cell and hand back the lookup's in-cell face. Since + * objectstack#35688 S3 the cell's editor IS the candidate list (no trigger + * button to press first): the list is open, the gate shows as a hint in its + * place, and "Browse all" sits under it. + */ +async function openEditor(cell: HTMLElement): Promise { fireEvent.click(cell); return await waitFor(() => { - const btn = cell.querySelector('button'); - expect(btn).toBeTruthy(); - return btn as HTMLButtonElement; + const panel = cell.querySelector('[data-testid="lookup-in-cell"]'); + expect(panel).toBeTruthy(); + return panel as HTMLElement; }); } +/** + * Esc where the user presses it: on whatever holds focus inside the cell's + * editor (the list's search box), so it reaches the grid's own key handling. + */ +function pressEscape(): void { + fireEvent.keyDown(document.activeElement ?? document.body, { key: 'Escape' }); +} + +/** The in-cell face's gate hint, or null when the list is usable. */ +function gateOf(panel: HTMLElement): HTMLElement | null { + return panel.querySelector('[data-testid="lookup-in-cell-gated"]'); +} + describe('objectui#7166 — the three retired keys were never delivered by this bag', () => { it('none of the three is on the copy set any more (the premise the rest of this file measures)', () => { // Control: the copy set is populated and still holds the key objectui#6875 @@ -252,19 +270,19 @@ describe('objectui#7166 — the three retired keys were never delivered by this // Declared: the author's `email` is previewed under each option, with the // key off the copy set — it arrived through the editor's schema spread. const declared = cellAt(container, 1); - fireEvent.click(await openEditor(declared)); + await openEditor(declared); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); await waitFor(() => { expect(document.querySelectorAll('[data-lookup-preview="email"]').length).toBeGreaterThan(0); }); expect(screen.getByText('p1@north.example')).toBeInTheDocument(); - fireEvent.keyDown(document.body, { key: 'Escape' }); + pressEscape(); await waitFor(() => expect(document.querySelectorAll('[data-lookup-preview="email"]').length).toBe(0)); // CONTROL — same reference, same records, nothing declared: the two-field // referenced schema derives no extra column, so there is no preview line. const control = cellAt(container, 2); - fireEvent.click(await openEditor(control)); + await openEditor(control); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); expect(document.querySelectorAll('[data-lookup-preview]').length).toBe(0); }); @@ -287,17 +305,17 @@ describe('objectui#7166 — the three retired keys were never delivered by this // Declared: `region` is a picker column, so it previews under each option. const declared = cellAt(container, 1); - fireEvent.click(await openEditor(declared)); + await openEditor(declared); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); await waitFor(() => { expect(document.querySelectorAll('[data-lookup-preview="region"]').length).toBeGreaterThan(0); }); - fireEvent.keyDown(document.body, { key: 'Escape' }); + pressEscape(); await waitFor(() => expect(document.querySelectorAll('[data-lookup-preview="region"]').length).toBe(0)); // CONTROL — nothing declared, nothing derived, no preview. const control = cellAt(container, 2); - fireEvent.click(await openEditor(control)); + await openEditor(control); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); expect(document.querySelectorAll('[data-lookup-preview]').length).toBe(0); }); @@ -326,17 +344,17 @@ describe('objectui#7166 — the three retired keys were never delivered by this // Declared: only the `south` half is offered — the author's hard scope // reached the picker with the key off the copy set. const declared = cellAt(container, 1); - fireEvent.click(await openEditor(declared)); + await openEditor(declared); await waitFor(() => expect(screen.getByText('Person 04')).toBeInTheDocument()); expect(screen.queryByText('Person 01')).not.toBeInTheDocument(); expect(ds.refQueries.some((q: any) => q?.$filter?.region === 'south')).toBe(true); - fireEvent.keyDown(document.body, { key: 'Escape' }); + pressEscape(); await waitFor(() => expect(screen.queryByText('Person 04')).not.toBeInTheDocument()); // CONTROL — the same six records, unscoped: the north half is offered too, // which is what makes the absence above a filter and not an empty fixture. const control = cellAt(container, 2); - fireEvent.click(await openEditor(control)); + await openEditor(control); await waitFor(() => expect(screen.getByText('Person 01')).toBeInTheDocument()); expect(screen.getByText('Person 04')).toBeInTheDocument(); }); From 03d23bdab1c7b00edcab6bcb8fd8202d07fed048 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 10:48:06 +0000 Subject: [PATCH 6/9] fix(components): in-cell input layer stays square and flat under a host theme (#36023) The console's theme rounds and lifts every [role=dialog] with !important, and the editor layer is a Radix popover, so the flat input face drew a 20px radius and a shadow in the browser. The face's radius and shadow utilities now carry the important modifier; an important utility sits in a cascade layer and outranks the unlayered theme rule. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE --- .../src/renderers/complex/dataTableCellOverlay.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/packages/components/src/renderers/complex/dataTableCellOverlay.tsx b/ui/packages/components/src/renderers/complex/dataTableCellOverlay.tsx index 39835d2af2c..a2f9713f315 100644 --- a/ui/packages/components/src/renderers/complex/dataTableCellOverlay.tsx +++ b/ui/packages/components/src/renderers/complex/dataTableCellOverlay.tsx @@ -178,10 +178,15 @@ const EDITOR_DENSITY_CLASS = cn( * A typed-input editor (`data-in-cell-face="input"`, objectstack#36023) turns * the layer into the cell itself: one row tall, square, no padding or shadow, * on the page's own background, framed by the 2px line the selected cell draws. + * + * Square and flat win with `!`: a host theme may round and lift every + * `[role=dialog]` with `!important` (the console's iOS layer does), and the + * layer is a Radix popover, so it carries that role. An important utility sits + * in a cascade layer and so outranks an unlayered important rule. */ // Spelled out in full: Tailwind finds classes by scanning for whole literals. const IN_CELL_INPUT_LAYER_CLASS = cn( - 'has-[[data-in-cell-face=input]]:p-0 has-[[data-in-cell-face=input]]:rounded-none has-[[data-in-cell-face=input]]:shadow-none', + 'has-[[data-in-cell-face=input]]:p-0 has-[[data-in-cell-face=input]]:rounded-none! has-[[data-in-cell-face=input]]:shadow-none!', 'has-[[data-in-cell-face=input]]:border-2 has-[[data-in-cell-face=input]]:bg-background has-[[data-in-cell-face=input]]:text-foreground', 'has-[[data-in-cell-face=input]]:min-h-(--radix-popper-anchor-height)', ); From fac409aa9d8e2f3529666b4aa699f021a0ddca03 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 10:49:55 +0000 Subject: [PATCH 7/9] chore(changeset): name Browse all in the in-cell record picker Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE --- .changeset/35688-in-cell-typed-lookup-rating.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/35688-in-cell-typed-lookup-rating.md b/.changeset/35688-in-cell-typed-lookup-rating.md index 7ff3ab978a3..813505be441 100644 --- a/.changeset/35688-in-cell-typed-lookup-rating.md +++ b/.changeset/35688-in-cell-typed-lookup-rating.md @@ -11,8 +11,8 @@ Metadata-protocol: none In the list grid's cell editor (the layer over the cell, `inCell`): -- 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. 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. -- 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, and Clear is offered while the cell holds a value. +- 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. +- 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), and Clear is offered while the cell holds a value. - 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). - 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. From 3f49c05216a35575370b26c1fa7e2f59750f35c3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 11:06:33 +0000 Subject: [PATCH 8/9] test(plugin-grid): the lookup exit-mode cases read the in-cell list A single lookup pick in a grid cell is now the whole edit (#35688), so the two exit-mode cases that pinned the popover era (pick stages, click-outside commits; Enter on the trigger) pin the in-cell list instead: a pick lands and closes the editor, and a press inside the open list keeps it while a press outside exits. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE --- .../src/__tests__/inlineEditExitMode.test.tsx | 61 ++++++++----------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/ui/packages/plugin-grid/src/__tests__/inlineEditExitMode.test.tsx b/ui/packages/plugin-grid/src/__tests__/inlineEditExitMode.test.tsx index 044618e3dc1..f0aa76e93b0 100644 --- a/ui/packages/plugin-grid/src/__tests__/inlineEditExitMode.test.tsx +++ b/ui/packages/plugin-grid/src/__tests__/inlineEditExitMode.test.tsx @@ -238,7 +238,12 @@ describe('ObjectGrid — injected lookup editor exits edit mode', () => { { field: 'manager', label: 'Manager', type: 'lookup' }, ]; - it('picking an option keeps the editor open; click-outside then exits and retains the value', async () => { + // objectstack#35688 S3: the cell's lookup editor IS the candidate list (no + // trigger to press first), and a single pick is the whole edit. These two + // cases used to pin the popover era (pick stages, click-outside commits; Enter + // on the trigger opens the dropdown); they now pin the in-cell list and + // the click-outside guard around it. + it('a pick in the in-cell list is the whole edit: the value lands and the editor closes', async () => { const ds = makeDataSource(); const { container } = renderGrid(ds, lookupCols); await waitFor(() => expect(screen.getByText('Row One')).toBeInTheDocument()); @@ -248,41 +253,22 @@ describe('ObjectGrid — injected lookup editor exits edit mode', () => { const tds = Array.from(row.querySelectorAll('td')); return tds[tds.length - 1] as HTMLElement; // manager is the last data column }; + const panel = () => managerTd().querySelector('[data-testid="lookup-in-cell"]') as HTMLElement | null; - // Enter edit mode, open the popover. + // Enter edit mode: the list is open at once, inside the cell. fireEvent.click(managerTd()); - const trigger = await waitFor(() => { - const btn = managerTd().querySelector('button'); - expect(btn).toBeTruthy(); - return btn as HTMLButtonElement; - }); - fireEvent.click(trigger); + await waitFor(() => expect(panel()).toBeTruthy()); - // Pick "Dev Admin" from the popover (rendered in a portal at ). - const option = await waitFor(() => { - const el = screen.getByText('Dev Admin'); - expect(el).toBeInTheDocument(); - return el; - }); - // Clicking inside the widget's own popover must NOT prematurely exit the - // editor — the click-outside guard treats the portal as part of the editor. + const option = await waitFor(() => within(panel()!).getByText('Dev Admin')); fireEvent.pointerDown(option); fireEvent.click(option); - // The staged value shows and the editor (trigger button) is still mounted. - await waitFor(() => - expect(within(managerTd()).getByText('Dev Admin')).toBeInTheDocument(), - ); - expect(managerTd().querySelector('button')).toBeTruthy(); - - // Now click truly outside → commit + exit. - fireEvent.pointerDown(screen.getByTestId('outside')); - await waitFor(() => expect(managerTd().querySelector('button')).toBeNull()); - // Value retained as a pending change. + // The editor closed on the pick, and the cell shows the picked record. + await waitFor(() => expect(panel()).toBeNull()); expect(within(managerTd()).getByText('Dev Admin')).toBeInTheDocument(); }); - it('Enter on the picker trigger does not prematurely exit edit mode', async () => { + it('a press inside the open list does not exit edit mode; a press outside does', async () => { const ds = makeDataSource(); const { container } = renderGrid(ds, lookupCols); await waitFor(() => expect(screen.getByText('Row One')).toBeInTheDocument()); @@ -292,17 +278,20 @@ describe('ObjectGrid — injected lookup editor exits edit mode', () => { const tds = Array.from(row.querySelectorAll('td')); return tds[tds.length - 1] as HTMLElement; }; + const panel = () => managerTd().querySelector('[data-testid="lookup-in-cell"]') as HTMLElement | null; fireEvent.click(managerTd()); - const trigger = await waitFor(() => { - const btn = managerTd().querySelector('button'); - expect(btn).toBeTruthy(); - return btn as HTMLButtonElement; - }); + await waitFor(() => expect(panel()).toBeTruthy()); - // Enter belongs to the picker (open its dropdown), NOT the cell — the editor - // must stay open. Only a single-line commits on Enter. - fireEvent.keyDown(trigger, { key: 'Enter' }); - expect(managerTd().querySelector('button')).toBeTruthy(); + // The click-outside guard treats the editor's own content as inside: a + // press on the list's search box keeps the editor. + const search = panel()!.querySelector('input') as HTMLInputElement; + fireEvent.pointerDown(search); + fireEvent.click(search); + expect(panel()).toBeTruthy(); + + // CONTROL — a press truly outside exits. + fireEvent.pointerDown(screen.getByTestId('outside')); + await waitFor(() => expect(panel()).toBeNull()); }); }); From c1e2e066157650a13ffbf543f3b5b568abc6dbc5 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 21 Nov 2026 11:42:17 +0000 Subject: [PATCH 9/9] fix(fields): a single pick from Browse all ends a list cell's edit In a list cell, Browse all's dialog handed a single pick to onChange only, so the editor stayed open with the value staged. The pick now commits as a pick from the in-cell list does, after the declared targets fill; a multiple pick still stages. Pinned through ObjectGrid to ds.update. Also: the rating scale fact is floored before its > 0 test, and its doc says a digit sets at most 9; the changeset says recents rings start empty once after the per-user key. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgTJobxYSxskrNbCuHE --- .../35688-in-cell-typed-lookup-rating.md | 4 +-- .../src/context/gridCellSelection.tsx | 3 ++- .../src/renderers/complex/data-table.tsx | 4 ++- .../fields/src/widgets/LookupField.tsx | 9 ++++++- ...inCellSelectMultipleRouting-35688.test.tsx | 25 ++++++++++++++++++- 5 files changed, 39 insertions(+), 6 deletions(-) diff --git a/.changeset/35688-in-cell-typed-lookup-rating.md b/.changeset/35688-in-cell-typed-lookup-rating.md index 813505be441..ddcf8607dce 100644 --- a/.changeset/35688-in-cell-typed-lookup-rating.md +++ b/.changeset/35688-in-cell-typed-lookup-rating.md @@ -12,8 +12,8 @@ Metadata-protocol: none In the list grid's cell editor (the layer over the cell, `inCell`): - 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. -- 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), and Clear is offered while the cell holds a value. +- 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. - 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). -- 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. +- 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. Forms, dialogs and the record page draw these widgets as before. No i18n key is added. diff --git a/ui/packages/components/src/context/gridCellSelection.tsx b/ui/packages/components/src/context/gridCellSelection.tsx index 54adf5d5c09..c72be55cf6f 100644 --- a/ui/packages/components/src/context/gridCellSelection.tsx +++ b/ui/packages/components/src/context/gridCellSelection.tsx @@ -47,7 +47,8 @@ export interface GridCellFacts { * A rating out of this many stars, set in place and never in an editor: on * the selected cell a digit key sets that many stars (0 clears), a click on * a star the cell draws (`data-rating-star`) sets it, and Backspace or - * Delete clears it; each commits. + * Delete clears it; each commits. A digit sets at most 9, so on a wider + * scale the top values are set by a click. */ stars?: number; /** diff --git a/ui/packages/components/src/renderers/complex/data-table.tsx b/ui/packages/components/src/renderers/complex/data-table.tsx index 4a38bb6ba75..9e0e63f0b42 100644 --- a/ui/packages/components/src/renderers/complex/data-table.tsx +++ b/ui/packages/components/src/renderers/complex/data-table.tsx @@ -3671,7 +3671,9 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => { /** The star count of a rating cell set in place (objectstack#36023), or `null`. */ const starsOf = (row: any, col: TableColumn): number | null => { const stars = factsOf(row, col)?.stars; - return typeof stars === 'number' && stars > 0 ? Math.floor(stars) : null; + // Whole stars first, then the floor: a host's 0.5 is no scale at all. + const whole = typeof stars === 'number' && Number.isFinite(stars) ? Math.floor(stars) : 0; + return whole > 0 ? whole : null; }; const setStars = (rowIndex: number, colIndex: number, count: number) => writeCell(rowIndex, colIndex, () => (count > 0 ? count : null)); diff --git a/ui/packages/fields/src/widgets/LookupField.tsx b/ui/packages/fields/src/widgets/LookupField.tsx index 5fc0443a25b..acb3f98357b 100644 --- a/ui/packages/fields/src/widgets/LookupField.tsx +++ b/ui/packages/fields/src/widgets/LookupField.tsx @@ -1342,16 +1342,23 @@ export function LookupField({ value, onChange, field, readonly, error: fieldErro ); const handleDialogSelectRecords = useCallback( (records: Record[]) => { + // In a list cell a single pick from Browse all is the whole edit, as a + // pick from the in-cell list is (objectstack#35688): the dialog hands + // the id to `onSelect` first, the row here, and the cell commits last, + // after the declared targets filled. A multiple pick stays staged. + const commitsCell = inCell && !multiple && records.length === 1; if (multiple || !onSelectRecord || records.length !== 1) { handlePickerSelectRecords(records); + if (commitsCell) onCommit?.(); return; } const row = records[0]; if (referenceTo) pushRecentLookupId(referenceTo, recordValue(row, idField) as string | number | undefined, perms.userId); setPickedRecords(records); onSelectRecord(recordToOption(row, declaredDisplayField, idField, effectiveDescriptionField, refObjectSchema, perms, referenceTo)); + if (commitsCell) onCommit?.(); }, - [multiple, onSelectRecord, handlePickerSelectRecords, referenceTo, idField, declaredDisplayField, effectiveDescriptionField, refObjectSchema, perms], + [multiple, onSelectRecord, handlePickerSelectRecords, referenceTo, idField, declaredDisplayField, effectiveDescriptionField, refObjectSchema, perms, inCell, onCommit], ); // ── Recently-used, quick-create, combined option list ──────────────────── diff --git a/ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx b/ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx index 1fd75333cfc..f16e333ee72 100644 --- a/ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx +++ b/ui/packages/plugin-grid/src/__tests__/inCellSelectMultipleRouting-35688.test.tsx @@ -17,7 +17,7 @@ * edit; on a select-first grid a rating is set by a digit, with no editor. */ import { describe, it, expect, vi, beforeAll, beforeEach, afterEach } from 'vitest'; -import { render, screen, waitFor, fireEvent, cleanup } from '@testing-library/react'; +import { render, screen, waitFor, fireEvent, cleanup, within } from '@testing-library/react'; import '@testing-library/jest-dom'; import React from 'react'; @@ -198,6 +198,29 @@ describe('ObjectGrid cell editor: lookups and ratings (objectstack#35688 S3)', ( await waitFor(() => expect(screen.getByText(/1 row modified/)).toBeInTheDocument()); }); + it('a single pick from Browse all ends the edit too, and saves the picked id', async () => { + const { container, ds } = renderGrid(true); + await waitFor(() => expect(screen.getByText('Design system')).toBeInTheDocument()); + + fireEvent.click(cellUnder(container, 'Tier')); + const catcher = container.querySelector('[data-slot="cell-type-catcher"]')!; + fireEvent.keyDown(catcher, { key: 'Enter' }); + const panel = await screen.findByTestId('lookup-in-cell'); + fireEvent.click(within(panel).getByTestId('browse-all-records')); + + // The full picker (a portal dialog): one click on a row is a single pick. + const row = await waitFor(() => { + const r = Array.from(document.querySelectorAll('[role="dialog"] tbody tr')).find((tr) => /Silver/.test(tr.textContent ?? '')); + expect(r).toBeTruthy(); + return r as HTMLElement; + }); + fireEvent.click(row); + + await waitFor(() => expect(container.querySelector('[data-slot="cell-editor-overlay"]')).toBeNull()); + await waitFor(() => expect(ds.update).toHaveBeenCalled()); + expect(ds.update.mock.calls[0].slice(0, 3)).toEqual([OBJECT, 'r1', { tier: 'silver' }]); + }); + it('on a select-first grid a digit sets the rating and opens no editor', async () => { const { container, ds } = renderGrid(true); await waitFor(() => expect(screen.getByText('Design system')).toBeInTheDocument());