-
Notifications
You must be signed in to change notification settings - Fork 0
🎨 Palette: Improve accessibility of TabBar and SaveRow components #20
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 2024-05-08 - TabBar and SaveRow Accessibility | ||
| **Learning:** Dynamic status messages in UI components (like success/error text in save bars) should be wrapped in an `aria-live="polite"` region with `role="status"` to ensure screen readers announce updates dynamically. Tab bars need explicit `role="tablist"` and `role="tab"` with `aria-selected` tracking the active state. | ||
| **Action:** When implementing custom interactive components like tabs or dynamic save notifications, always verify standard ARIA roles and live regions are included. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ export default function TabBar({ tabs, active, onChange, className = '', tone = | |
| : 'flex flex-wrap gap-1 p-1 bg-gray-100 rounded-xl w-fit'; | ||
|
|
||
| return ( | ||
| <div class={`${rail} ${className}`}> | ||
| <div role="tablist" class={`${rail} ${className}`}> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using |
||
| {tabs.map((tab) => { | ||
| const selected = active === tab.id; | ||
| const base = | ||
|
|
@@ -32,6 +32,8 @@ export default function TabBar({ tabs, active, onChange, className = '', tone = | |
| return ( | ||
| <button | ||
| key={tab.id} | ||
| role="tab" | ||
| aria-selected={selected} | ||
| type="button" | ||
| onClick={() => onChange(tab.id)} | ||
| class={`${base} ${sizing} ${selected ? activeCls : idleCls}`} | ||
|
|
||
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.
To improve the accessibility of the status message, consider adding
aria-atomic="true"so that the entire message is announced by screen readers when it updates. Additionally, whilerole="status"is appropriate for general updates, usingrole="alert"for error messages ensures they are announced assertively to the user. Note thatrole="status"has an implicitaria-live="polite", so that attribute can be omitted if the role is static.