Skip to content

Commit c001b86

Browse files
authored
Merge pull request #321 from codegouvfr/fix/pagination-aria-hidden
fixed missing aria-disabled label on pagination
2 parents cc6dae4 + 94ed50a commit c001b86

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Pagination.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ export const Pagination = memo(
100100

101101
const parts = getPaginationParts({ count, defaultPage });
102102

103+
const activePage = parts.find(part => part.active);
104+
const currentPage = activePage?.number;
105+
const isCurrentPageFirstPage = currentPage === 1;
106+
const isCurrentPageLastPage = currentPage === count;
107+
103108
return (
104109
<nav
105110
id={id}
@@ -122,7 +127,7 @@ export const Pagination = memo(
122127
getPageLinkProps(1).className
123128
),
124129
"aria-disabled":
125-
count > 0 && defaultPage > 1 ? true : undefined,
130+
count > 0 && isCurrentPageFirstPage ? true : undefined,
126131
role: "link"
127132
}}
128133
>
@@ -143,7 +148,7 @@ export const Pagination = memo(
143148
),
144149
classes.link
145150
),
146-
"aria-disabled": defaultPage <= 1 ? true : undefined,
151+
"aria-disabled": isCurrentPageFirstPage ? true : undefined,
147152
role: "link"
148153
}}
149154
>
@@ -181,7 +186,7 @@ export const Pagination = memo(
181186
),
182187
classes.link
183188
),
184-
"aria-disabled": defaultPage < count ? true : undefined,
189+
"aria-disabled": isCurrentPageLastPage ? true : undefined,
185190
role: "link"
186191
}}
187192
>
@@ -198,7 +203,7 @@ export const Pagination = memo(
198203
fr.cx("fr-pagination__link", "fr-pagination__link--last"),
199204
classes.link
200205
),
201-
"aria-disabled": defaultPage < count ? true : undefined
206+
"aria-disabled": isCurrentPageLastPage ? true : undefined
202207
}}
203208
>
204209
{t("last page")}

0 commit comments

Comments
 (0)