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
21 changes: 21 additions & 0 deletions .changeset/35678-floating-selection-bar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@object-ui/plugin-grid': patch
'@object-ui/components': patch
'@object-ui/types': patch
'@object-ui/app-shell': patch
---

feat(plugin-grid): selected rows get one small bar floating at the bottom centre of the list

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

Selecting rows in a grid now shows one bar floating at the bottom centre of the list area: 「已选 N 条」 and ×, up to three labelled actions, and the rest under 「更多」. When the selection offers no more than three actions they are all buttons, so a lone Delete is a button; over three, Delete goes behind 「更多」 with the rest. The bar sits above the footer calc row, the list keeps room after its last row so that row scrolls fully clear of the bar, and when every loaded row is selected and more match, the bar offers 「选择全部 N 条」. × or Esc clears the selection; Esc that belongs to a field, or to another open menu or dialog, does not.

The same bar serves the object list page, a record's child-table tabs, the side record and embedded tables. The old bottom strip and the list page's 「已选」 face in the view bar are both retired, so the top of the list page no longer changes when rows are selected. On the list page, where rows draw no actions of their own, one selected record offers that record's actions; elsewhere the bar offers the bulk actions at any count. A narrow list gives actions back to 「更多」 until the bar fits on one line.

- `@object-ui/plugin-grid`: `BulkActionBar` is redrawn as the floating bar; its props gain `singleRowMenu`. `useListPageScope(scope)` replaces the unpublished `useListPageBarHost`.
- `@object-ui/types` / `@object-ui/components`: `DataTableSchema.floatingBar` is a runtime slot (refused by the zod twin like the other runtime slots). The table floats it over its scroll box, above its summary row, with room after its last row.
- `@object-ui/app-shell`: the list page header and the view bar no longer swap to a selection face.

This supersedes the selection behaviour in the list-page entry of this release (no Actions column on the list page): the selection is no longer shown in the page bar, up to three actions are buttons and a lone Delete is one, and grids outside a list page no longer draw a bottom bulk bar.
34 changes: 18 additions & 16 deletions docs/qa/platform-checklist/areas/records-forms.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions examples/app-showcase/e2e/bulk-capability-gate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ test('selection bar hides capability-gated inline defs from a caller without the
await selectAll.waitFor({ state: 'visible', timeout: 25_000 });
await selectAll.click();

// The bar offers the ungated defs: it draws the first two as buttons and
// the rest behind its "⋮" (`SELECTION_EXPOSED_ACTIONS`, ui plugin-grid
// `SelectionPageBar.tsx`, citing #35554 「露出一到两个,其余进⋮」), where a
// def is a `row-context-bulk-NAME` menu item instead of a
// The bar offers the ungated defs: it draws the first three as buttons and
// the rest behind its More (`SELECTION_EXPOSED_ACTIONS`, ui plugin-grid
// `SelectionBar.tsx`, objectstack#35678: up to three labelled actions, the rest behind More),
// where a def is a `row-context-bulk-NAME` menu item instead of a
// `bulk-action-NAME` button. All four ungated defs are read, so none of
// them can drop out of the bar unnoticed.
await expect(page.getByTestId('bulk-action-set_labels')).toBeVisible({ timeout: 15_000 });
await expect(page.getByTestId('bulk-action-assign_team')).toBeVisible();
await expect(page.getByTestId('bulk-action-reassign_account')).toBeVisible();
await page.getByTestId('selection-actions-more').click();
await expect(page.getByTestId('row-context-bulk-reassign_account')).toBeVisible();
await expect(page.getByTestId('row-context-bulk-reschedule')).toBeVisible();

// …and neither gated def, as a button or as an item of the open "⋮" — the
Expand Down
294 changes: 252 additions & 42 deletions ui/e2e/list-no-actions-column-35554.spec.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ async function rowBoxes(): Promise<HTMLElement[]> {
}

/**
* objectstack#35554 — the selection's actions on the list page: the page bar's
* selection face, its exposed buttons and the ones behind its "⋮". Returns the
* objectstack#35678 — the selection's actions on the list page: the floating
* selection bar, its exposed buttons and the ones behind its More. Returns the
* bar and the action names it carries.
*/
async function selectionBar(): Promise<{ bar: HTMLElement; names: string[] }> {
const bar = await screen.findByTestId('list-selection-bar', undefined, { timeout: 5000 });
const bar = await screen.findByTestId('bulk-actions-bar', undefined, { timeout: 5000 });
const names = within(bar).queryAllByTestId(/^bulk-action-/).map((el) => el.getAttribute('data-testid')!.slice('bulk-action-'.length));
const more = within(bar).queryByTestId('selection-actions-more');
if (more) {
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('objectui#12462 — a bulk-wired, record-scoped list_toolbar action lea

// Zero rows: the header has the plain action and not the duplicate; no bar.
expect(addToCampaignIn(header)).toBeNull();
expect(screen.queryByTestId('list-selection-bar')).toBeNull();
expect(screen.queryByTestId('bulk-actions-bar')).toBeNull();

// Two rows: the selection carries the action; the header still lacks it.
await tickRows(2);
Expand All @@ -239,9 +239,9 @@ describe('objectui#12462 — a bulk-wired, record-scoped list_toolbar action lea
expect(addToCampaignIn(header)).toBeNull();
expect(within(header).getByRole('button', { name: /Refresh Scores/ })).toBeInTheDocument();

// Cancelling the selection brings the page bar back.
await act(async () => { fireEvent.click(within(bar).getByTestId('list-selection-cancel')); });
await waitFor(() => expect(screen.queryByTestId('list-selection-bar')).toBeNull(), { timeout: 5000 });
// × clears the selection and the bar goes.
await act(async () => { fireEvent.click(within(bar).getByTestId('bulk-selection-clear')); });
await waitFor(() => expect(screen.queryByTestId('bulk-actions-bar')).toBeNull(), { timeout: 5000 });
});

it('the view wires it in a `bulkActionDefs` entry: the header lacks it, the bar carries it', async () => {
Expand Down
59 changes: 14 additions & 45 deletions ui/packages/app-shell/src/views/objectViewPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import type { useObjectViewToolbarAffordances } from './objectViewToolbarAfforda
import type { useObjectViewHeaderToolbar } from './objectViewHeaderToolbar.js';
import type { useObjectViewHeaderChrome } from './objectViewHeaderChrome.js';
import type { ConsoleObjectViewProps } from './ObjectView.js';
import { useListPageBarHost } from '@object-ui/plugin-grid';
import { useListPageScope } from '@object-ui/plugin-grid';

/**
* objectstack#35446 — the list header's width under which it takes
Expand Down Expand Up @@ -167,39 +167,18 @@ export function ObjectViewPageHeader(props: ObjectViewPageBarProps) {
const { objectDef, objectPluralLabel, foldedHeaderActions } = props;
const actionProps = props;
const pluralLabel = objectPluralLabel(objectDef);
// objectstack#35554 — the page bar's selection slot (`useListPageBarHost`,
// `@object-ui/plugin-grid`). The list in this page column fills it while
// rows are selected — 「已选 N 条」, Cancel and the actions for what is
// selected — and this bar shows it in place of its title and actions.
const [selectionSlot, setSelectionSlot] = useState<HTMLDivElement | null>(null);
// objectstack#35554 — this page column is a list page's scope
// (`useListPageScope`, `@object-ui/plugin-grid`): the list in it draws no
// row-end controls. A selection changes nothing up here: the list floats
// its own selection bar at its bottom (objectstack#35678).
const [pageColumn, setPageColumn] = useState<HTMLElement | null>(null);
const headerRootRef = useCallback((el: HTMLDivElement | null) => {
setPageColumn(el?.parentElement ?? null);
}, []);
const pageBar = useListPageBarHost(selectionSlot, pageColumn);
useListPageScope(pageColumn);
return (
<div className="hidden sm:block" ref={headerRootRef}>
{/* objectstack#35554 — the selection face: the object's name, then
what the list draws into the slot. Always mounted, so the slot
is there the moment a row is ticked; shown only while one is. */}
<div
className={pageBar.selecting
? 'relative shrink-0 border-b bg-background z-10'
: 'hidden'}
data-testid="list-selection-page-bar"
aria-hidden={pageBar.selecting ? undefined : true}
>
{/* The list bar's measure (objectstack#35548): 44px, 13px type. */}
<div className="flex h-11 items-center gap-2 px-4">
<span className="shrink-0 text-[13px] font-semibold leading-5 text-muted-foreground">
{pluralLabel}
</span>
<span aria-hidden="true" className="shrink-0 text-muted-foreground/60">/</span>
<div ref={setSelectionSlot} className="flex min-w-0 flex-1 items-center" />
</div>
</div>
<PageHeader
className={pageBar.selecting ? 'hidden' : undefined}
posture="list"
// The object's plural: the page lists its records (objectui#11696).
// The view is named in the view bar below, by its switcher.
Expand Down Expand Up @@ -271,11 +250,11 @@ export function ObjectViewBarObjectName({
/**
* objectstack#35878 — the right end of the view bar: the list's own tools (its
* search), then the page's acts (`ObjectViewPageBarActions`: create, then ⋮
* More at the edge, objectstack#35678). While rows are selected the end shows
* what the selection offers instead (objectstack#35554's slot,
* `useListPageBarHost`), and ⋮ More stays the last control with the same
* icon. The page's acts are drawn from `sm` up; a phone keeps its floating
* create button.
* More at the edge, objectstack#35678). A selection changes nothing here: the
* list floats its own selection bar at its bottom (objectstack#35678). The
* page column is registered as a list page's scope (`useListPageScope`), so
* its list draws no row-end controls. The page's acts are drawn from `sm` up;
* a phone keeps its floating create button.
*/
export function ObjectViewBarTrailing({ tools, ...props }: ObjectViewPageBarProps & { tools: ReactNode }) {
const setHosted = useContext(ListViewBarHostContext);
Expand All @@ -284,28 +263,18 @@ export function ObjectViewBarTrailing({ tools, ...props }: ObjectViewPageBarProp
setHosted(true);
return () => setHosted(false);
}, [setHosted]);
const [selectionSlot, setSelectionSlot] = useState<HTMLDivElement | null>(null);
const [pageColumn, setPageColumn] = useState<HTMLElement | null>(null);
const rootRef = useCallback((el: HTMLDivElement | null) => {
setPageColumn(el?.closest<HTMLElement>(`[${OBJECT_VIEW_PAGE_COLUMN_ATTR}]`) ?? null);
}, []);
const pageBar = useListPageBarHost(selectionSlot, pageColumn);
useListPageScope(pageColumn);
return (
<div
ref={rootRef}
className={cn(VIEW_BAR_END_INSET, pageBar.selecting ? 'flex min-w-0 flex-1 items-center' : 'flex shrink-0 items-center gap-0.5')}
className={cn(VIEW_BAR_END_INSET, 'flex shrink-0 items-center gap-0.5')}
data-testid="list-view-bar-end"
>
{/* Always mounted, so the slot is there the moment a row is ticked. */}
<div
ref={setSelectionSlot}
className={pageBar.selecting ? 'flex min-w-0 flex-1 items-center' : 'hidden'}
data-testid="list-selection-page-bar"
aria-hidden={pageBar.selecting ? undefined : true}
/>
{/* Hidden, not unmounted, while rows are selected: the search keeps
its term and the header acts keep following the selection. */}
<div className={pageBar.selecting ? 'hidden' : 'flex items-center gap-0.5'} data-testid="list-view-bar-tools">
<div className="flex items-center gap-0.5" data-testid="list-view-bar-tools">
{tools}
<span className="hidden items-center gap-1 pl-1 sm:flex" data-testid="list-view-bar-actions">
<ObjectViewPageBarActions {...props} />
Expand Down
27 changes: 27 additions & 0 deletions ui/packages/components/src/renderers/complex/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
disableInnerScroll = false,
rowGroups,
summaryRow,
floatingBar,
isRowEditable,
// Read ONLY to diagnose it. `data-table` does not resolve `bind` and the
// objectui#6575 ruling is explicit that it must not start — see
Expand Down Expand Up @@ -5401,6 +5402,14 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
* height stability instead. */}
</>
)}
{/* objectstack#35678 — the room kept after the last row while a
bar floats over the bottom of the scroll box: the last row
scrolls clear of it. Not a row anyone reads. */}
{floatingBar != null && (
<tr aria-hidden="true" className="h-16 border-0 hover:bg-transparent" data-testid="data-table-floating-bar-room">
<td colSpan={fullRowColSpan} className="p-0" />
</tr>
)}
</TableBody>
{/* The summary row (objectstack#35548): the table's own last row,
held at the bottom of the scroll box, each figure in its
Expand Down Expand Up @@ -5464,6 +5473,24 @@ const DataTableRenderer = ({ schema }: { schema: DataTableSchema }) => {
style={{ right: rightShadow.right, bottom: rightShadow.bottom }}
/>
)}
{/* objectstack#35678 — the host's floating bar (`floatingBar`), centred
at the bottom of the scroll box, above the summary row. A zero-height
box after the scroll box, held at the bottom of the viewport while a
table taller than its page runs past it (`sticky`). */}
{floatingBar != null && (
<div className="pointer-events-none sticky bottom-0 z-30 h-0" data-testid="data-table-floating-bar">
<div
className={cn(
"absolute inset-x-0 flex justify-center px-4",
// 2.0625rem is the summary row's h-8 plus its 1px border-t:
// the bar sits 1rem above the row instead of over it.
summaryRow ? "bottom-[calc(2.0625rem+1rem)]" : "bottom-3",
)}
>
{floatingBar}
</div>
</div>
)}
</div>

{/* Pagination — hidden when only one page (no controls would be actionable) */}
Expand Down
9 changes: 9 additions & 0 deletions ui/packages/plugin-grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,15 @@ const schema: ObjectGridBlockNode = {
deprecated legacy alias, read only when `selection` is absent. Declaring bulk
actions auto-enables multi-select, so the two keys agree by construction.

Selected rows get one bar floating at the bottom centre of the grid
(`BulkActionBar`, objectstack#35678): the count and ×, up to three labelled
actions and the rest under More (Delete last), and "Select all N" when every
loaded row is selected and more match. × or Esc clears the selection. The bar
floats above the summary row, and the grid keeps room after its last row so
that row scrolls clear of it. A host that draws the object list page registers
its page column with `useListPageScope(element)`: there rows draw no actions of their
own, and one selected record offers that record's actions in the bar.

To react to a selection in React, pass the `onRowSelect` **component prop** —
see [Row callbacks are component props](#row-callbacks-are-component-props).

Expand Down
Loading
Loading