-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: main
Are you sure you want to change the base?
Conversation
update snapshots to include focus guards and aria attributes for improved accessibility
src/components/Tabs/Tabs.tsx
Outdated
@@ -120,6 +121,15 @@ const Tabs: FC<TabsProps> = ({ | |||
} | |||
}; | |||
|
|||
// Update document title with the selected tab title for a11y purposes | |||
useEffect(() => { | |||
const tempBaseTitle = document.title; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/Tabs/Tabs.tsx
Outdated
if (!baseTitle) setBaseTitle(tempBaseTitle); | ||
const selectedTab = tabs[activeTab]; | ||
const tabTitle = typeof selectedTab?.title === "string" ? selectedTab.title : ""; | ||
document.title = tabTitle ? `${baseTitle} | ${tabTitle}` : baseTitle; |
There was a problem hiding this comment.
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;
}
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better lock package version
useEffect(() => { | ||
return () => { | ||
document.title = baseTitleRef.current; | ||
}; | ||
}, []); |
There was a problem hiding this comment.
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;
}}, []);
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