Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/compact-table-footer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tailor-platform/app-shell": patch
---

Make the `DataTable` footer more compact at phone widths. When the footer is narrower than 480px, `DataTable.Pagination` hides the page-size switcher, shortens the page text to `1/5`, and shrinks the page buttons from 36px to 28px, so the row count and the page buttons fit on one line. The selection count is shortened to `3/240 selected` in the bulk-action bar and in `DataTable.Pagination`; screen readers still get the full text. With rows selected, the footer now takes two lines at 375px instead of three. The English row count now uses `row` or `rows` by count instead of `row(s)`.
6 changes: 3 additions & 3 deletions docs-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@
],
"hashes": {
"typeSurface": "413c66caec0a0bf8",
"outline": "a4288a1435b46ed4",
"outline": "6d76610bcbb15d98",
"snapshot": "a97e067c66e46ef6",
"outputMd": "c32c7ccf13528bf1",
"outputMd": "ea6d433dbee15988",
"examples": "8adc119ac0d7152c"
}
},
Expand Down Expand Up @@ -1840,7 +1840,7 @@
"packages/core/skills/app-shell-patterns/references/components/combobox.md": "c79cd0fe175187e3",
"packages/core/skills/app-shell-patterns/references/components/command-palette.md": "7e5bc675a593791a",
"packages/core/skills/app-shell-patterns/references/components/csv-importer.md": "10c04c78bb846c9a",
"packages/core/skills/app-shell-patterns/references/components/data-table.md": "c32c7ccf13528bf1",
"packages/core/skills/app-shell-patterns/references/components/data-table.md": "ea6d433dbee15988",
"packages/core/skills/app-shell-patterns/references/components/date-picker.md": "376e7d4ad14c2934",
"packages/core/skills/app-shell-patterns/references/components/default-header.md": "375e55f4b12fa2be",
"packages/core/skills/app-shell-patterns/references/components/default-sidebar.md": "9b1672c71b6db3ff",
Expand Down
22 changes: 14 additions & 8 deletions docs-src/components/data-table.docs.outline.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,16 +261,22 @@ Add a name, minimum-quantity, or status filter, then edit or remove its chip. Th

`DataTable.Pagination` automatically displays a row count and selection info text on the left side of the pagination bar based on context state:

| Condition | Displayed text |
| ----------------------------------------- | ------------------------ |
| `total` is provided | `X row(s)` |
| Rows selected and `total` is provided | `Y of X row(s) selected` |
| Rows selected and `total` is not provided | `Y row(s) selected` |
| No selection enabled and no `total` | _(nothing displayed)_ |
| Condition | Displayed text |
| ----------------------------------------- | --------------------------------------------------- |
| `total` is provided | `X rows` (`1 row`) |
| Rows selected and `total` is provided | `Y of X rows selected` (`Y/X selected` when narrow) |
| Rows selected and `total` is not provided | `Y rows selected` (`1 row selected`) |
| No selection enabled and no `total` | _(nothing displayed)_ |

Row selection is enabled by providing `rowSelection` or `onSelectionChange` to `useDataTable`. The `total` value comes from `DataTableData.total`. While the footer shows the bulk-action bar (see [Selection actions](#selection-actions)), the bar owns the selection count and this text is omitted.

In a narrow footer (under 480px wide, such as on a phone), the controls wrap onto more lines instead of being clipped. The **Rows per page** label is hidden, and the page text is shortened to `1 / 5`. Both stay available to screen readers. This only works inside `DataTable.Footer`, because the footer's own width is measured, not the viewport's.
In a narrow footer (under 480px wide, such as on a phone), the footer is compacted so the row count and the page buttons fit on one line:

- The page-size switcher is hidden.
- The page text is shortened from `Page 1 / 5` to `1/5`, and the selection text from `Y of X rows selected` to `Y/X selected`. Screen readers still get the full text.
- The page buttons shrink from 36px to 28px, which stays above the 24px minimum target size.

Controls that still do not fit wrap onto another line instead of being clipped. This only works inside `DataTable.Footer`, because the footer's own width is measured, not the viewport's.

When pagination changes page or page size, `DataTable.Table` resets its own scroll container to the top automatically. That applies whether navigation comes from the built-in `DataTable.Pagination` or from custom controls using the same table context.

Expand Down Expand Up @@ -720,7 +726,7 @@ Confirmation, eligibility checks, and execution remain consumer-owned. A real ap
- **Return the promise from `onClick`.** While it is pending, the bar disables every action and shows a spinner on the running one, so a slow request can't be fired twice. Neither success nor rejection changes selection; there is no `keepSelection` option. A rejection is logged as `[DataTable] Selection action "…" failed`; showing it to the user is up to your handler.
- **Confirm dialogs can hand a later request back with `run`.** An `onClick` that only opens a dialog returns nothing. Keep the `run` helper and call it from the dialog's confirm button — `await run(deleteVendors(ids))` — to track that request in the bar. This only tracks pending state; it does not clear selection. Clear is disabled while a request is pending, and pending state survives the bar closing and reopening. Use controlled `rowSelection` to remove only successful ids, or call the explicit `clearSelection` helper if clearing every page is intentional.
- **Selection spans pages.** The header checkbox adds or removes only the current page; **Clear** empties everything.
- **Three actions stay inline.** The fourth onward collapse into a **More actions** menu, in array order. Put the most frequent first; a destructive action placed last sits safely in the menu. When the footer is narrower than 480px (for example, on a phone), every action moves into the menu, so the bar keeps to one line and the table rows stay visible. The menu button then gets an outline, like the inline actions.
- **Three actions stay inline.** The fourth onward collapse into a **More actions** menu, in array order. Put the most frequent first; a destructive action placed last sits safely in the menu. When the footer is narrower than 480px (for example, on a phone), every action moves into the menu, so the bar keeps to one line and the table rows stay visible. The menu button then gets an outline, like the inline actions, and the count is shortened to `3/240 selected` (screen readers still get `3 of 240 selected`).
- **Confirm destructive actions.** `variant: "destructive"` only styles the action. Open a confirm dialog from `onClick` before deleting — see the [confirm pattern](../patterns/interaction-confirm.md).
- **The bar stays reachable.** In `<Layout fill>` the footer is already pinned. On a page that scrolls, the bar sticks to the bottom of the viewport while rows are selected and settles back into place at the end of the table. It sticks to the nearest scrolling container: inside a scrolling drawer or panel it rides that container instead, and inside a wrapper that clips its overflow (such as a card with `overflow: hidden`) it simply stays in the footer.
- **Share presentation with `rowActions`.** Both action types extend the non-generic [`DataTableAction`](#datatableaction) (`id`, `label`, `icon`, `variant`). Keep row predicates on `RowAction<TRow>` and bulk business rules in the consumer's ID-based handler.
Expand Down
22 changes: 14 additions & 8 deletions docs/components/data-table.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 21 additions & 4 deletions packages/core/src/components/data-table/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ export const dataTableLabels = defineI18nLabels({
// Clear button's accessible name extends its visible text, so it is still
// unambiguous when read outside the bar.
bulkActionsLabel: "Bulk actions",
// Shorter than Pagination's "N of M row(s) selected": the bar shares the
// Shorter than Pagination's "N of M rows selected": the bar shares the
// footer line with the pagination controls.
selectionCount: (props: { selected: number; total: number | null }) =>
props.total === null
? `${props.selected} selected`
: `${props.selected} of ${props.total} selected`,
// Shown in place of `selectionCount` in a footer under 480px wide; the
// full text stays for screen readers.
selectionCountShort: (props: { selected: number; total: number | null }) =>
props.total === null
? `${props.selected} selected`
: `${props.selected}/${props.total} selected`,
selectionMoreActions: "More actions",
selectionClear: "Clear",
selectionClearLabel: "Clear selection",
Expand All @@ -77,10 +83,15 @@ export const dataTableLabels = defineI18nLabels({
paginationLast: "Last page",
paginationRowsPerPage: "Rows per page",
paginationPage: "Page",
paginationTotalRows: (props: { total: number }) => `${props.total} row(s)`,
paginationTotalRows: (props: { total: number }) =>
`${props.total} ${props.total === 1 ? "row" : "rows"}`,
paginationSelectedOfTotal: (props: { selected: number; total: number }) =>
`${props.selected} of ${props.total} row(s) selected`,
paginationSelectedRows: (props: { selected: number }) => `${props.selected} row(s) selected`,
`${props.selected} of ${props.total} ${props.total === 1 ? "row" : "rows"} selected`,
// Shown in place of `paginationSelectedOfTotal` in a footer under 480px wide.
paginationSelectedOfTotalShort: (props: { selected: number; total: number }) =>
`${props.selected}/${props.total} selected`,
paginationSelectedRows: (props: { selected: number }) =>
`${props.selected} ${props.selected === 1 ? "row" : "rows"} selected`,

// Filters
addFilter: "Add filter",
Expand Down Expand Up @@ -188,6 +199,10 @@ export const dataTableLabels = defineI18nLabels({
props.total === null
? `${props.selected} 行を選択中`
: `${props.total} 行中 ${props.selected} 行を選択中`,
selectionCountShort: (props: { selected: number; total: number | null }) =>
props.total === null
? `${props.selected} 行を選択中`
: `${props.selected}/${props.total} 行を選択中`,
selectionMoreActions: "その他の操作",
selectionClear: "解除",
selectionClearLabel: "選択を解除",
Expand All @@ -210,6 +225,8 @@ export const dataTableLabels = defineI18nLabels({
paginationTotalRows: (props: { total: number }) => `${props.total} 行`,
paginationSelectedOfTotal: (props: { selected: number; total: number }) =>
`${props.total} 行中 ${props.selected} 行を選択中`,
paginationSelectedOfTotalShort: (props: { selected: number; total: number }) =>
`${props.selected}/${props.total} 行を選択中`,
paginationSelectedRows: (props: { selected: number }) => `${props.selected} 行を選択中`,

// Filters
Expand Down
Loading
Loading