Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(a11y): fix issues from the a11y report #498

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

LefterisKiou
Copy link
Contributor

@LefterisKiou LefterisKiou commented Feb 7, 2025

6.3.2 -> Modal.tsx
6.4.1 -> Tabs.tsx
6.5.1 -> Drawer.tsx, package.json (added react-focus-lock)

6.11.1 -> ToggleSwitch.tsx
6.12.1 -> Tooltip.tsx

@LefterisKiou LefterisKiou self-assigned this Feb 7, 2025
update snapshots to include focus guards and aria attributes for improved accessibility
@@ -120,6 +121,15 @@ const Tabs: FC<TabsProps> = ({
}
};

// Update document title with the selected tab title for a11y purposes
useEffect(() => {
const tempBaseTitle = document.title;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can directly use document.title instead of storing it in a temporary variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!baseTitle) setBaseTitle(tempBaseTitle);
const selectedTab = tabs[activeTab];
const tabTitle = typeof selectedTab?.title === "string" ? selectedTab.title : "";
document.title = tabTitle ? `${baseTitle} | ${tabTitle}` : baseTitle;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This updates document.title on every render, even if the title hasn't changed. I think something like this would work:

const newTitle = tabTitle ? `${baseTitle} | ${tabTitle}` : baseTitle;

if (document.title !== newTitle) {
  document.title = newTitle;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -109,6 +109,7 @@
"core-js": "^3.38.1",
"deepmerge": "^4.3.1",
"framer-motion": "^6.5.1",
"react-focus-lock": "^2.13.5",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better lock package version

Comment on lines +125 to +129
useEffect(() => {
return () => {
document.title = baseTitleRef.current;
};
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for return keyword

useEffect(() => () => {
document.title = baseTitleRef.current;
}}, []);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants