Skip to content

Commit 3f4401e

Browse files
committed
fix(plugin-list): keep the declared empty-state Create, adapt sort pins to one row per field
- A view that declares addRecord.enabled keeps its empty-state Create with or without a host handler, as before; a host create path now adds it. - The two removable-only controls read each field from its own row and expect "Add sort" to start on the first free field. - object-view's renderListView branch is host-only, and Studio folds its New into the list through it with showCreate: false, so its create path stays as it was. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVW2q9rsHS1vCrQ8Q9
1 parent c99f176 commit 3f4401e

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

‎.changeset/27520-list-toolbar-filter-sort-empty.md‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
'@object-ui/plugin-list': patch
33
'@object-ui/components': patch
4-
'@object-ui/plugin-view': patch
54
'@object-ui/i18n': patch
65
---
76

@@ -13,5 +12,5 @@ Metadata-protocol: none
1312
- **Unfinished filter rows.** A filter-panel row with no value yet is no longer counted on the Filter badge, no longer turns the list into "No matching records", and is no longer handed to the host's `onFilterChange`, so the console does not store it as the user's list state and it does not come back after a reload. The panel still shows the row so it can be finished.
1413
- **Date sort direction.** The sort picker names a `date` or `datetime` field's direction "Oldest → Newest" / "Newest → Oldest" instead of "A → Z" / "Z → A". The list hands the picker each field's type.
1514
- **One sort row per field.** A field another sort row already orders by is unavailable in the other rows, "Add sort" starts on the first field no row holds, and it is disabled once every field has a row.
16-
- **Clear search.** The "No matching records" a search produced offers "Clear search". The clear button inside the search box is now named "Clear search" too.
17-
- **Create on an empty list.** An empty list offers Create whenever the host gives a create path and the user may create, without the view having to declare an inline `addRecord` block. An author's `addRecord: { enabled: false }` or `userActions.addRecordForm: false` still withholds it, and the `object-view` renderer no longer hands its list a create path when the author turned Create off (`showCreate: false` or `operations.create: false`).
15+
- **Clear search.** The "No matching records" a search produced offers "Clear search".
16+
- **Create on an empty list.** An empty list offers Create whenever the host gives a create path and the user may create, without the view having to declare an inline `addRecord` block. An author's `addRecord: { enabled: false }` or `userActions.addRecordForm: false` still withholds it, and a view that declares the inline block keeps its Create as before.

‎ui/packages/plugin-list/src/ListView.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3869,7 +3869,10 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
38693869
}, [onSearchChange]);
38703870

38713871
// objectstack#27520 row 17 — see `toolbarFlags.emptyStateAddRecord`.
3872-
const emptyStateOffersCreate = toolbarFlags.emptyStateAddRecord && !!props.onAddRecord;
3872+
// A view that declares the inline block keeps its empty-state Create as
3873+
// before; a host-supplied create path now offers it too.
3874+
const emptyStateOffersCreate =
3875+
toolbarFlags.showAddRecord || (toolbarFlags.emptyStateAddRecord && !!props.onAddRecord);
38733876

38743877
// --- NavigationConfig support ---
38753878
// No assertion, deliberately. `schema.navigation` is the spec-derived
@@ -6399,7 +6402,6 @@ export const ListView = React.forwardRef<ListViewHandle, ListViewProps>(({
63996402
variant="ghost"
64006403
size="sm"
64016404
className="absolute right-0.5 top-1/2 -translate-y-1/2 h-5 w-5 p-0 hover:bg-muted-foreground/20"
6402-
aria-label={t('list.clearSearch')}
64036405
onClick={() => handleSearchChange('')}
64046406
>
64056407
<X className="h-3 w-3" />

‎ui/packages/plugin-list/src/__tests__/ListView.sortRemovableOnly-11943.test.tsx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,20 @@ describe('a field the Sort picker keeps only for the current sort is removable o
221221
]);
222222
fireEvent.click(screen.getByRole('button', { name: /add sort/i }));
223223
await waitFor(() => expect(sortRowTriggers()).toHaveLength(2));
224-
// With nothing flagged, "Add sort" seeds the first entry, as it always has.
225-
expect(sortRowTriggers()[1]).toHaveTextContent('Title');
224+
// With nothing flagged, "Add sort" seeds the first entry no row holds:
225+
// `Title` is the first row's, so the new row starts on `Priority`
226+
// (objectstack#27520, one row per field).
227+
expect(sortRowTriggers()[1]).toHaveTextContent('Priority');
226228
});
227229

228230
it('control: with full read and no served projection, the unreadable and refused fields are ordinary options', async () => {
229231
mount({ first: 'secret_note', sort: ['secret_note', 'remote_status'], perms: FULL_READ, projection: false });
232+
// Each read from the row that sorts by it: in the OTHER row a field is
233+
// unavailable because a row already holds it (objectstack#27520), which
234+
// is not the removable-only flag this control is about.
230235
const options = await openSort();
231236
expect(options.find((o) => o.label === 'Secret Note')).toEqual({ label: 'Secret Note', disabled: false });
232-
expect(options.find((o) => o.label === 'Remote Status')).toEqual({ label: 'Remote Status', disabled: false });
237+
const secondRow = await optionsOf(sortRowTriggers()[1]);
238+
expect(secondRow.find((o) => o.label === 'Remote Status')).toEqual({ label: 'Remote Status', disabled: false });
233239
});
234240
});

‎ui/packages/plugin-view/src/ObjectView.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,11 +3192,7 @@ export const ObjectView: React.FC<ObjectViewProps> = ({
31923192
onRowClick: handleRowClick,
31933193
className: 'h-full',
31943194
refreshKey,
3195-
// objectstack#27520 row 17 — the list's empty state offers Create
3196-
// whenever it is handed a create path, so it is handed one only where
3197-
// the author left Create on (the same two switches as the New button
3198-
// below; the create grant is the list's own `mayCreate` read).
3199-
onAddRecord: schema.showCreate !== false && operations.create !== false ? handleCreate : undefined,
3195+
onAddRecord: handleCreate,
32003196
});
32013197
}
32023198
// #endregion object-view HOST-COMPOSITION SURFACE (objectui#5097)

0 commit comments

Comments
 (0)