From 757de91005552fbd5d77d3915477c008fc38047a Mon Sep 17 00:00:00 2001 From: Hiroki Uemura Date: Sat, 24 Oct 2026 11:37:36 +0900 Subject: [PATCH 1/6] fix(data-table): keep the footer usable at phone widths DataTable.Pagination now wraps its controls instead of letting the table frame clip them, so Next and Last stay tappable at 375px. Below a 480px footer width, the "Rows per page" label and the "Page" word become sr-only, and the bulk-action bar moves every action into the More actions menu so the table rows stay visible. Refs tailor-inc/platform-planning#2209 Co-Authored-By: Claude Opus 5.5 --- .changeset/narrow-table-footer.md | 5 + .../components/data-table.docs.outline.md | 4 +- docs/components/data-table.md | 4 +- .../core/src/components/data-table/footer.tsx | 5 +- .../src/components/data-table/pagination.tsx | 121 ++++++++++++------ .../data-table/selection-bar.test.tsx | 36 ++++++ .../components/data-table/selection-bar.tsx | 40 +++++- 7 files changed, 167 insertions(+), 48 deletions(-) create mode 100644 .changeset/narrow-table-footer.md diff --git a/.changeset/narrow-table-footer.md b/.changeset/narrow-table-footer.md new file mode 100644 index 000000000..d1d8b9371 --- /dev/null +++ b/.changeset/narrow-table-footer.md @@ -0,0 +1,5 @@ +--- +"@tailor-platform/app-shell": patch +--- + +Keep the `DataTable` footer usable at phone widths. `DataTable.Pagination` now wraps its controls onto more lines instead of letting the frame clip them, so **Next** and **Last** stay tappable. When the footer is narrower than 480px, the **Rows per page** label is hidden and the page text is shortened to `1 / 5` (both stay available to screen readers). The bulk-action bar also moves every action into the **More actions** menu at that width, so it keeps to one line and the table rows stay visible. diff --git a/docs-src/components/data-table.docs.outline.md b/docs-src/components/data-table.docs.outline.md index bb5ccd31c..60788cecc 100644 --- a/docs-src/components/data-table.docs.outline.md +++ b/docs-src/components/data-table.docs.outline.md @@ -239,6 +239,8 @@ By default `DataTable.Filters` renders the active filter chips plus the **Add fi 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. + 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. ## Column pinning, visibility & ordering @@ -739,7 +741,7 @@ return ( - **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. +- **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. - **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 `` 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` and bulk business rules in the consumer's ID-based handler. diff --git a/docs/components/data-table.md b/docs/components/data-table.md index ec29c64e8..31d2ed7a7 100644 --- a/docs/components/data-table.md +++ b/docs/components/data-table.md @@ -233,6 +233,8 @@ By default `DataTable.Filters` renders the active filter chips plus the **Add fi 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. + 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. ## Column pinning, visibility & ordering @@ -1155,7 +1157,7 @@ return ( - **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. +- **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. - **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 `` 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` and bulk business rules in the consumer's ID-based handler. diff --git a/packages/core/src/components/data-table/footer.tsx b/packages/core/src/components/data-table/footer.tsx index 1445557f2..67bef90ba 100644 --- a/packages/core/src/components/data-table/footer.tsx +++ b/packages/core/src/components/data-table/footer.tsx @@ -19,7 +19,10 @@ function DataTableFooter({ children, className }: { children?: ReactNode; classN data-slot="data-table-footer" data-selecting={selecting ? "" : undefined} className={cn( - "astw:flex astw:shrink-0 astw:items-center astw:border-t astw:border-border astw:px-4 astw:py-2", + // A named container so Pagination can compact itself by the footer's + // own width, not the viewport's. The selection bar measures the same + // width in JS (see NARROW_FOOTER_WIDTH in selection-bar.tsx). + "astw:@container/data-table-footer astw:flex astw:shrink-0 astw:items-center astw:border-t astw:border-border astw:px-4 astw:py-2", offersBulkActions && "astw:transition-colors astw:motion-reduce:transition-none", selecting && [ "astw:flex-wrap astw:gap-x-3 astw:gap-y-2", diff --git a/packages/core/src/components/data-table/pagination.tsx b/packages/core/src/components/data-table/pagination.tsx index 8b2a5dd53..7ff39fe32 100644 --- a/packages/core/src/components/data-table/pagination.tsx +++ b/packages/core/src/components/data-table/pagination.tsx @@ -6,6 +6,14 @@ import { useDataTableContext } from "./context"; import { useDataTableT } from "./i18n"; import { isSelectionBarOpen } from "./selection-bar"; +/** + * Visually hides a label while the footer is narrower than + * `NARROW_FOOTER_WIDTH` (see `selection-bar.tsx`), keeping it for screen + * readers. Outside `DataTable.Footer` the container never matches, so the + * label stays visible. + */ +const NARROW_FOOTER_SR_ONLY = "astw:@max-[480px]/data-table-footer:sr-only"; + export interface DataTablePaginationProps { /** * Available page-size options shown in a dropdown selector. @@ -57,19 +65,29 @@ export function DataTablePagination({ pageSizeOptions }: DataTablePaginationProp return ( // Beside the bar, flex-1 instead of w-full lets both share one line and // wraps the controls onto a line of their own only when they don't fit. + // In a narrow footer (phone widths) the row count, the page-size switcher + // and the page buttons wrap onto separate lines instead of being clipped by + // the table frame, and the "Rows per page" / "Page" words become sr-only.
{rowInfoText && ( -
{rowInfoText}
+
+ {rowInfoText} +
)} -
+
{pageSizeOptions && pageSizeOptions.length > 0 && (
- + {t("paginationRowsPerPage")} { + if (item) setPageSize(Number(item)); + }} + className="astw:w-17.5" + /> +
+ )} + {/* The page text and its buttons wrap as one unit, so the buttons never + split across lines. */} +
+ {totalPages !== null && ( + <> + {/* The full "Page 1 / 5" stays one text node for screen readers + and text queries; a narrow footer shows "1 / 5" in its place. */} - {t("paginationRowsPerPage")} + {t("paginationPage")} {currentPage} / {totalPages} + + - { From ef346ab2dc5de2ebe2d5aa18231c02ed2f461e56 Mon Sep 17 00:00:00 2001 From: Hiroki Uemura Date: Sat, 7 Nov 2026 17:57:40 +0900 Subject: [PATCH 5/6] docs(data-table): resync docs manifest Co-Authored-By: Claude Opus 5.5 --- docs-manifest.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs-manifest.json b/docs-manifest.json index 2cf95ac98..fbec9f4ed 100644 --- a/docs-manifest.json +++ b/docs-manifest.json @@ -474,9 +474,9 @@ ], "hashes": { "typeSurface": "33eb2bdd6be1c774", - "outline": "eec5179512971f96", + "outline": "897ca46d7e1cc3d7", "snapshot": "a97e067c66e46ef6", - "outputMd": "7133811af89213ef", + "outputMd": "efddfbc0a8340685", "examples": "e7100d7517f72495" } }, @@ -1788,7 +1788,7 @@ "packages/core/skills/app-shell-patterns/references/components/combobox.md": "dfb775c7c4307409", "packages/core/skills/app-shell-patterns/references/components/command-palette.md": "7e5bc675a593791a", "packages/core/skills/app-shell-patterns/references/components/csv-importer.md": "53d3c795ca21b9dc", - "packages/core/skills/app-shell-patterns/references/components/data-table.md": "7133811af89213ef", + "packages/core/skills/app-shell-patterns/references/components/data-table.md": "efddfbc0a8340685", "packages/core/skills/app-shell-patterns/references/components/date-picker.md": "df6777c49ca5c7e2", "packages/core/skills/app-shell-patterns/references/components/default-header.md": "375e55f4b12fa2be", "packages/core/skills/app-shell-patterns/references/components/default-sidebar.md": "8e24da61e95b6434", From 0229f3c5c120814ea2a81b62d9ac3643bbd8f191 Mon Sep 17 00:00:00 2001 From: Hiroki Uemura Date: Sun, 8 Nov 2026 11:42:53 +0900 Subject: [PATCH 6/6] fix(data-table): outline the actions menu when the footer is narrow When the footer is narrow, every bulk action moves into the More actions menu. The menu button now uses the outline style of the inline actions, so it stands out more than the Clear button. Co-Authored-By: Claude Opus 5.5 --- .changeset/narrow-table-footer.md | 2 +- docs-manifest.json | 6 +++--- docs-src/components/data-table.docs.outline.md | 2 +- docs/components/data-table.md | 2 +- .../core/src/components/data-table/selection-bar.test.tsx | 6 +++++- packages/core/src/components/data-table/selection-bar.tsx | 8 +++++++- 6 files changed, 18 insertions(+), 8 deletions(-) diff --git a/.changeset/narrow-table-footer.md b/.changeset/narrow-table-footer.md index 7a0ffcbc1..77e18bbdc 100644 --- a/.changeset/narrow-table-footer.md +++ b/.changeset/narrow-table-footer.md @@ -2,4 +2,4 @@ "@tailor-platform/app-shell": patch --- -Keep the `DataTable` footer usable at phone widths. `DataTable.Pagination` now wraps its controls onto more lines instead of letting the frame clip them, so **Next** and **Last** stay tappable. When the footer is narrower than 480px, the **Rows per page** label is hidden and the page text is shortened to `1 / 5` (both stay available to screen readers, and the label now names the page-size select). The bulk-action bar also moves every action into the **More actions** menu at that width, so it keeps to one line and the table rows stay visible. +Keep the `DataTable` footer usable at phone widths. `DataTable.Pagination` now wraps its controls onto more lines instead of letting the frame clip them, so **Next** and **Last** stay tappable. When the footer is narrower than 480px, the **Rows per page** label is hidden and the page text is shortened to `1 / 5` (both stay available to screen readers, and the label now names the page-size select). The bulk-action bar also moves every action into the **More actions** menu at that width, so it keeps to one line and the table rows stay visible. The menu button gets an outline at that width, so it stands out more than **Clear**. diff --git a/docs-manifest.json b/docs-manifest.json index fbec9f4ed..7e32f1b35 100644 --- a/docs-manifest.json +++ b/docs-manifest.json @@ -474,9 +474,9 @@ ], "hashes": { "typeSurface": "33eb2bdd6be1c774", - "outline": "897ca46d7e1cc3d7", + "outline": "d4d12b967d1942ba", "snapshot": "a97e067c66e46ef6", - "outputMd": "efddfbc0a8340685", + "outputMd": "0114d7644bbd65f4", "examples": "e7100d7517f72495" } }, @@ -1788,7 +1788,7 @@ "packages/core/skills/app-shell-patterns/references/components/combobox.md": "dfb775c7c4307409", "packages/core/skills/app-shell-patterns/references/components/command-palette.md": "7e5bc675a593791a", "packages/core/skills/app-shell-patterns/references/components/csv-importer.md": "53d3c795ca21b9dc", - "packages/core/skills/app-shell-patterns/references/components/data-table.md": "efddfbc0a8340685", + "packages/core/skills/app-shell-patterns/references/components/data-table.md": "0114d7644bbd65f4", "packages/core/skills/app-shell-patterns/references/components/date-picker.md": "df6777c49ca5c7e2", "packages/core/skills/app-shell-patterns/references/components/default-header.md": "375e55f4b12fa2be", "packages/core/skills/app-shell-patterns/references/components/default-sidebar.md": "8e24da61e95b6434", diff --git a/docs-src/components/data-table.docs.outline.md b/docs-src/components/data-table.docs.outline.md index 60788cecc..26a65f6d7 100644 --- a/docs-src/components/data-table.docs.outline.md +++ b/docs-src/components/data-table.docs.outline.md @@ -741,7 +741,7 @@ return ( - **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. +- **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. - **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 `` 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` and bulk business rules in the consumer's ID-based handler. diff --git a/docs/components/data-table.md b/docs/components/data-table.md index 31d2ed7a7..b64f9f840 100644 --- a/docs/components/data-table.md +++ b/docs/components/data-table.md @@ -1157,7 +1157,7 @@ return ( - **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. +- **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. - **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 `` 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` and bulk business rules in the consumer's ID-based handler. diff --git a/packages/core/src/components/data-table/selection-bar.test.tsx b/packages/core/src/components/data-table/selection-bar.test.tsx index a9f65c0b4..12c2038f4 100644 --- a/packages/core/src/components/data-table/selection-bar.test.tsx +++ b/packages/core/src/components/data-table/selection-bar.test.tsx @@ -199,7 +199,9 @@ describe("DataTable selection actions", () => { wrapper, }); expect(within(getBar()).queryByRole("button", { name: "Delete" })).toBeNull(); - await user.click(within(getBar()).getByRole("button", { name: "More actions" })); + const menuTrigger = within(getBar()).getByRole("button", { name: "More actions" }); + expect(menuTrigger.className).not.toContain("astw:border-border"); + await user.click(menuTrigger); await user.click(await screen.findByRole("menuitem", { name: "Delete" })); expect(onDelete).toHaveBeenCalledExactlyOnceWith(["unseen", "3"], expect.any(Object)); }); @@ -231,6 +233,8 @@ describe("DataTable selection actions", () => { return; } expect(inlineButton).toBeNull(); + // The menu holds every action here, so it is outlined like them. + expect(menuTrigger!.className).toContain("astw:border-border"); await user.click(menuTrigger!); await user.click(await screen.findByRole("menuitem", { name: "Archive" })); expect(onArchive).toHaveBeenCalledExactlyOnceWith(["1"], expect.any(Object)); diff --git a/packages/core/src/components/data-table/selection-bar.tsx b/packages/core/src/components/data-table/selection-bar.tsx index 9a2010ecc..5fac2d785 100644 --- a/packages/core/src/components/data-table/selection-bar.tsx +++ b/packages/core/src/components/data-table/selection-bar.tsx @@ -166,7 +166,13 @@ export function DataTableSelectionBar>() { + // When narrow, the menu holds every action, so it takes the + // inline actions' outline and stands out from Clear. +