Skip to content

Commit

Permalink
#24 - fix: fix missing aria-label on paginator
Browse files Browse the repository at this point in the history
  • Loading branch information
svenvandescheur committed Jan 26, 2024
1 parent 2dbb4e0 commit dc925f6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/components/paginator/paginator.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export const PaginatorComponent: Story = {
labelCurrentPageRange: "{pageStart} - {pageEnd} of {pageCount}",
labelGoToPage: "Go to",
labelPageSize: "Show rows",
labelPagination: "Pagination",
labelPrevious: "Go to previous page",
labelNext: "Go to next page",
},
Expand Down Expand Up @@ -67,6 +68,7 @@ export const PaginatorComponentWithSpinner: Story = {
labelGoToPage: "Go to",
labelLoading: "Loading",
labelPageSize: "Show rows",
labelPagination: "Pagination",
labelPrevious: "Go to previous page",
labelNext: "Go to next page",
onPageChange: () => new Promise((resolve) => setTimeout(resolve, 1000)),
Expand All @@ -77,6 +79,7 @@ export const PaginatorComponentWithSpinner: Story = {
const previousButton = canvas.getByLabelText("Go to previous page");
const nextButton = canvas.getByLabelText("Go to next page");
canvas.getByRole("navigation");
canvas.getByLabelText("Pagination");
canvas.getByText("Show rows");
canvas.getByText("Go to");

Expand Down
10 changes: 9 additions & 1 deletion src/components/paginator/paginator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export type PaginatorProps = {
/** The page size (accessible) label. */
labelPageSize: string;

/** The pagination (accessible) label. */
labelPagination: string;

/** The go to previous page (accessible) label. */
labelPrevious: string;

Expand Down Expand Up @@ -82,6 +85,7 @@ export const Paginator: React.FC<PaginatorProps> = ({
labelCurrentPageRange = "{pageStart} - {pageEnd} of {pageCount}",
labelGoToPage = "Go to",
labelPageSize = "Show rows",
labelPagination = "Pagination",
labelPrevious = "Go to previous page",
labelNext = "Go to next page",
labelLoading,
Expand Down Expand Up @@ -179,7 +183,11 @@ export const Paginator: React.FC<PaginatorProps> = ({
};

return (
<nav className="mykn-paginator" {...props}>
<nav
className="mykn-paginator"
aria-label={formatMessage(labelPagination, context)}
{...props}
>
<div className="mykn-paginator__section mykn-paginator__section--form">
{pageSizeOptions.length > 0 && (
<>
Expand Down

0 comments on commit dc925f6

Please sign in to comment.