Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .changeset/35688-in-cell-pickers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@object-ui/fields': patch
'@object-ui/plugin-grid': patch
'@object-ui/components': patch
'@object-ui/i18n': patch
---

feat(fields): in a list grid's cell editor, select, multi-select, tags, date, time and colour open ready to pick

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

The widget contract `FieldWidgetComponentProps` gains two optional host keys, `inCell` (draw the face for a grid cell's editor) and `onCommit` (the user has finished: write the last `onChange` value and close). `FieldEditWidget` forwards both, and `ObjectGrid`'s cell editor passes them. A host that passes neither renders every widget exactly as before.

In the cell editor of every grid `ObjectGrid` draws:

- **Single select and status** show their option list at once, with a search box that filters as you type. The arrow keys move through the list, Enter or a click picks, and the pick is saved; the selection stays on the cell. With nothing picked, Enter commits as before and Escape cancels.
- **Multi-select** (and a select declared `multiple`) is the same list with check marks: each pick toggles, and the edit is saved when you move on.
- **Tags** list this record's tags with check marks; unchecking removes one, and text that matches no tag is added from the list's leading "Add" row (Enter).
- **Date and date-time** open their calendar at once while the typed value stays visible and editable in the text box. The calendar offers Today, Tomorrow, Next week (seven days from today) and Clear. On a date, picking a day or a quick pick saves and closes; on a date-time, a day keeps the calendar open for the time, as in forms.
- **Time** opens the browser's time picker when the editor opens.
- **Colour** shows the hex box first (Enter saves, Escape leaves) and a row of swatches plus the browser's colour picker; a swatch saves and closes.
- A value picked this way hands the keyboard focus back to the selected cell, and in a grid that edits on a single click, the click that picked it no longer opens the editor again.

`@object-ui/i18n` adds the strings these faces show in every locale: `fields.datePicker.nextWeek`, `fields.datePicker.clearPick`, `fields.options.search`, `fields.options.noMatches`, `fields.tags.add`, `fields.color.swatches`, `fields.color.custom`.

Forms, dialogs and the record page keep their current controls.
9 changes: 9 additions & 0 deletions content/docs/frontend/plugins/plugin-grid.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,15 @@ through the host's data source (`dataSource.update`) with no callback to wire.
window the layer opens upward, near the right edge it shifts left, and a
cell half hidden behind a frozen column or the header is scrolled into view
first. Scrolling the cell out of sight commits the edit.
- **Pickers open ready to pick** (objectstack#35688): a single select or
status shows its option list at once, with a search box that filters as you
type; the arrow keys and Enter (or a click) pick, and the pick is saved. A
multi-select is the same list with check marks, and tags list the field's
tags with an "Add" row for new text; both save when you move on. A date or
date-time opens its calendar while the value stays typeable in its box, with
Today, Tomorrow, Next week (seven days from today) and Clear; on a date, a
day or a quick pick saves. A time opens the browser's time picker, and a
colour offers swatches beside its hex box (a swatch saves, Escape leaves).

To own persistence in a React host, supply `onCellChange` as a **component
prop** — it is not a schema key.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,24 @@ const LEDGER: Readonly<Record<string, LedgerRow>> = {
readers: ['props@fields/src/widgets/AvatarField.tsx', 'props@fields/src/widgets/FileField.tsx', 'props@fields/src/widgets/ImageField.tsx'],
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.
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',
],
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',
],
why: 'RUNTIME SLOT (objectstack#35688) — a host-supplied function (the grid cell editor\'s commit); JSON has no '
+ 'function value (the objectui#6124 shape).',
},
// ── runtime-only, by an existing ruling ─────────────────────────────────
field: {
readers: [
Expand Down
17 changes: 16 additions & 1 deletion ui/packages/components/src/renderers/complex/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4981,6 +4981,16 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
if (wasSelected && togglesCell(row, col)) toggleCell(rowIndex, colIndex);
return;
}
// objectstack#35688 — a click inside the open editor (an
// option of the in-cell list, still in the DOM when its click
// lands) is the editor's own. When that pick has just
// committed, `startEdit`'s same-cell guard has already been
// cleared, so the click would open the editor again; this
// render still says the cell is editing, so stop here.
if (isEditing) {
e.stopPropagation();
return;
}
if (isEditable && singleClickEdit && !hasTextSelectionIn(e.currentTarget)) {
e.stopPropagation();
startEdit(row, col.accessorKey);
Expand Down Expand Up @@ -5131,7 +5141,12 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
pendingRow: rowHasChanges ? pendingRows.of(row, rowKey) : row,
value: editValue,
stage: stageEdit,
commit: (v?: any) => saveEdit(true, v),
// objectstack#35688 — a pick that commits hands the
// focus back to the selected cell, as Enter does.
commit: (v?: any) => {
focusSelectionRef.current = selectFirst;
saveEdit(true, v);
},
cancel: cancelEdit,
});
if (node != null) {
Expand Down
14 changes: 14 additions & 0 deletions ui/packages/fields/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ The app-shell `ActionParamDialog` uses these to render declared action params
through the exact same widgets as the object form — with a drift test pinning
param support ⊇ form support.

### The grid cell editor's face (`inCell`, `onCommit`)

`FieldEditWidget` forwards two optional host keys of `FieldWidgetComponentProps`
to the widget it draws. `inCell` asks for the face a list grid's cell editor
needs: a single select or multi-select field draws a searchable list of its
options that is open from the start, a tags field the same list of this
record's tags (plus an "Add" row for new text), a date opens its calendar (with today, tomorrow, next
week and clear picks) while its text stays typeable, a time opens the browser
picker, and a colour offers swatches. `onCommit` is the host's "write the last
`onChange` value and close", which the date picker calls after a day or a quick
pick and the in-cell colour face after a swatch.
A host that passes neither gets the form faces unchanged; `ObjectGrid` passes
both.

### Resolving declared action params

An action param is declared either inline (`name` + `type`) or field-backed
Expand Down
Loading
Loading