Skip to content

Commit

Permalink
Merge pull request #179 from ConductionNL/feature/WOO-56/WCAG-improve…
Browse files Browse the repository at this point in the history
…ments

feature/WOO-56/WCAG-improvements
  • Loading branch information
remko48 authored Jan 30, 2024
2 parents eb431c5 + 0c63a8d commit 6a67901
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- **Version 2.2 (breaking changes from 2.1.x)**

- 2.2.45: Updated Pagination and select to ensure more WCAG compliancy.
- 2.2.44: Updated PrimaryTopNav to allow font-weight.
- 2.2.43: Updated DownloadCard to allow size as string.
- 2.2.42:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@conduction/components",
"version": "2.2.44",
"version": "2.2.45",
"description": "React (Gatsby) components used within the Conduction Skeleton Application (and its implementations)",
"main": "lib/index.js",
"scripts": {
Expand Down
27 changes: 27 additions & 0 deletions src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface PaginationProps {
currentPage: number;
setCurrentPage: React.Dispatch<React.SetStateAction<number>>;
ariaLabels: {
pagination: string;
nextPage: string;
previousPage: string;
page: string;
Expand All @@ -28,6 +29,32 @@ export const Pagination: React.FC<PaginationProps> = ({
}) => {
if (totalPages < 1) return <></>; // no pages available

const setAttributes = (): void => {
const setRoleToPresentation = (selector: string) => {
document.querySelectorAll(selector).forEach((element) => {
if (element.getAttribute("role") !== "list") element.setAttribute("role", "list");
});
};

setRoleToPresentation('ul[role*="navigation"][class*="Pagination"][aria-label="Pagination"]');
};

React.useEffect(() => {
setAttributes();
}, []);

React.useEffect(() => {
const setRoleToPresentation = (selector: string) => {
document.querySelectorAll(selector).forEach((element) => {
if (element.getAttribute("aria-label") !== ariaLabels.pagination) {
element.setAttribute("aria-label", ariaLabels.pagination);
}
});
};

setRoleToPresentation('ul[role*="list"][class*="Pagination"]');
}, [ariaLabels.pagination]);

return (
<ReactPaginate
className={clsx(styles.container, layoutClassName && layoutClassName)}
Expand Down
3 changes: 3 additions & 0 deletions src/components/formFields/select/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ const setAttributes = (): void => {
const setRoleToPresentation = (selector: string, role: string) => {
document.querySelectorAll(selector).forEach((element) => {
if (element.getAttribute("role") !== "presentation") element.setAttribute("role", role);
element.removeAttribute("aria-relevant");
element.removeAttribute("aria-atomic");
element.removeAttribute("aria-live");
});
};

Expand Down

0 comments on commit 6a67901

Please sign in to comment.