A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: give table pagination controls accessible names (#11134)
Shahmir Varqha42e2f723e3b0
diff --git a/frontend/src/components/data-table/__tests__/pagination.test.tsx b/frontend/src/components/data-table/__tests__/pagination.test.tsxindex 6a94bb0dca..d484e96ec9 100644--- a/frontend/src/components/data-table/__tests__/pagination.test.tsx+++ b/frontend/src/components/data-table/__tests__/pagination.test.tsx@@ -1,7 +1,91 @@/* Copyright 2026 Marimo. All rights reserved. */+import { getCoreRowModel, useReactTable } from "@tanstack/react-table";+import { fireEvent, render, screen } from "@testing-library/react";import { expect, test } from "vitest";-import { matchingPageRanges } from "../pagination";+import { TooltipProvider } from "@/components/ui/tooltip";+import { DataTablePagination, matchingPageRanges } from "../pagination";++function PaginationHarness({+ totalPages = 3,+ loading = false,+}: {+ totalPages?: number;+ loading?: boolean;+}) {+ const table = useReactTable({+ locale: "en-US",+ data: [],+ columns: [],+ getCoreRowModel: getCoreRowModel(),+ manualPagination: true,+ pageCount: totalPages,+ });+ return (+ <TooltipProvider>+ <DataTablePagination table={table} tableLoading={loading} />+ </TooltipProvider>+ );+}++test("named navigation controls preserve page updates and boundaries", () => {+ render(<PaginationHarness />);+ expect(screen.getByRole("button", { name: "First page" })).toBeDisabled();+ expect(screen.getByRole("button", { name: "Previous page" })).toBeDisabled();+ fireEvent.click(screen.getByRole("button", { name: "Next page" }));+ expect(+ screen.getByRole("button", { name: "Choose page, current page 2 of 3" }),+ ).toBeEnabled();+ fireEvent.click(screen.getByRole("button", { name: "Last page" }));+ expect(screen.getByRole("button", { name: "Next page" })).toBeDisabled();+ expect(screen.getByRole("button", { name: "Last page" })).toBeDisabled();+ fireEvent.click(screen.getByRole("button", { name: "Previous page" }));+ fireEvent.click(screen.getByRole("button", { name: "First page" }));+ expect(+ screen.getByRole("button", { name: "Choose page, current page 1 of 3" }),+ ).toBeEnabled();+ expect(screen.getByRole("button", { name: "First page" })).toBeDisabled();+ expect(screen.getByRole("button", { name: "Previous page" })).toBeDisabled();+ expect(screen.getByRole("button", { name: "Next page" })).toBeEnabled();+ expect(screen.getByRole("button", { name: "Last page" })).toBeEnabled();+});++test("loading prevents navigation and a single page disables controls", () => {+ const { rerender } = render(<PaginationHarness loading={true} />);+ fireEvent.click(screen.getByRole("button", { name: "Next page" }));+ fireEvent.click(screen.getByRole("button", { name: "Last page" }));+ expect(+ screen.getByRole("button", { name: "Choose page, current page 1 of 3" }),+ ).toBeEnabled();+ rerender(<PaginationHarness />);+ fireEvent.click(screen.getByRole("button", { name: "Next page" }));+ expect(+ screen.getByRole("button", { name: "Choose page, current page 2 of 3" }),+ ).toBeEnabled();+ rerender(<PaginationHarness key="single-page" totalPages={1} />);+ for (const name of [+ "First page",+ "Previous page",+ "Next page",+ "Last page",+ "Choose page, current page 1 of 1",+ ]) {+ expect(screen.getByRole("button", { name })).toBeDisabled();+ }+});++test("page picker exposes named dialog and search", () => {+ render(<PaginationHarness />);+ fireEvent.click(+ screen.getByRole("button", { name: "Choose page, current page 1 of 3" }),+ );+ expect(+ screen.getByRole("dialog", { name: "Choose page" }),+ ).toBeInTheDocument();+ expect(+ screen.getByRole("combobox", { name: "Search pages" }),+ ).toBeInTheDocument();+});test("empty prefix returns no ranges", () => {expect(matchingPageRanges("", 500)).toEqual([]);diff --git a/frontend/src/components/data-table/pagination.tsx b/frontend/src/components/data-table/pagination.tsxindex be57feb0b7..5be917c8d7 100644--- a/frontend/src/components/data-table/pagination.tsx+++ b/frontend/src/components/data-table/pagination.tsx@@ -117,6 +117,7 @@ export const DataTablePagination = <TData,>({size="xs"variant="text"data-testid="first-page-button"+ aria-label="First page"className="hidden h-6 w-5 p-0 lg:flex"onClick={() => handlePageChange(() => table.setPageIndex(0))}onMouseDown={Events.preventFocus}@@ -130,6 +131,7 @@ export const DataTablePagination = <TData,>({size="xs"variant="text"data-testid="previous-page-button"+ aria-label="Previous page"className="h-6 w-5 p-0"onClick={() => handlePageChange(() => table.previousPage())}onMouseDown={Events.preventFocus}@@ -156,6 +158,7 @@ export const DataTablePagination = <TData,>({size="xs"variant="text"data-testid="next-page-button"+ aria-label="Next page"className="h-6 w-5 p-0"onClick={() => handlePageChange(() => table.nextPage())}onMouseDown={Events.preventFocus}@@ -169,6 +172,7 @@ export const DataTablePagination = <TData,>({size="xs"variant="text"data-testid="last-page-button"+ aria-label="Last page"className="hidden h-6 w-5 p-0 lg:flex"onClick={() =>handlePageChange(() =>@@ -306,14 +310,24 @@ export const PageSelector = ({: "opacity-50 cursor-default",)}data-testid="page-select"+ aria-label={`Choose page, current page ${currentPage} of ${totalPages}`}disabled={totalPages <= 1}>{currentPage}<ChevronDown className="h-3 w-3 opacity-50 mb-px" /></button></PopoverTrigger>- <PopoverContent className="w-36 p-0" align="center" sideOffset={6}>- <Command shouldFilter={false} value={String(currentPage)}>+ <PopoverContent+ className="w-36 p-0"+ align="center"+ sideOffset={6}+ aria-label="Choose page"+ >+ <Command+ label="Search pages"+ shouldFilter={false}+ value={String(currentPage)}+ ><CommandInputplaceholder={`Page (1–${totalPages})`}rootClassName="px-2 h-8"