🎨 Palette: Improve Accessibility for WikiTabs and WikiCollapsible#29
🎨 Palette: Improve Accessibility for WikiTabs and WikiCollapsible#29aicoder2009 wants to merge 2 commits intomainfrom
Conversation
Co-authored-by: aicoder2009 <127642633+aicoder2009@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Improves accessibility semantics for wiki UI primitives by adding ARIA roles/states to WikiTabs and adding stable ID-based control/panel relationships to WikiCollapsible.
Changes:
- Add
role="tablist"on the tabs container androle="tab"+aria-selected+tabIndexon each tab button. - Add
useId()-generatedaria-controls/idwiring plusaria-expandedand dynamicaria-labelto the collapsible toggle. - Add a short internal note in
.jules/palette.mdcapturing the accessibility approach.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/components/wiki/wiki-tabs.tsx | Adds ARIA tab roles/states to the tab strip. |
| src/components/wiki/wiki-collapsible.tsx | Adds useId-based aria-controls/id mapping and expanded/label attributes. |
| .jules/palette.md | Documents the accessibility learning/action for these widgets. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <div className="flex border-b border-wiki-border-light" role="tablist"> | ||
| {tabs.map((tab) => ( | ||
| <button | ||
| key={tab.id} | ||
| role="tab" | ||
| aria-selected={tab.active ? "true" : "false"} | ||
| tabIndex={tab.active ? 0 : -1} |
There was a problem hiding this comment.
role="tab"/role="tablist" is being applied, but the tabs are not programmatically associated with a tab panel (no id on the tab and no aria-controls pointing at a corresponding role="tabpanel"). This can confuse assistive tech because it announces a tabs widget without the required relationships. Consider either (a) extending Tab to include a panel id and wiring id+aria-controls (and updating consuming markup to use role="tabpanel" + aria-labelledby), or (b) removing the tab roles if this component is only a visual switcher.
| <div className="flex border-b border-wiki-border-light" role="tablist"> | |
| {tabs.map((tab) => ( | |
| <button | |
| key={tab.id} | |
| role="tab" | |
| aria-selected={tab.active ? "true" : "false"} | |
| tabIndex={tab.active ? 0 : -1} | |
| <div className="flex border-b border-wiki-border-light"> | |
| {tabs.map((tab) => ( | |
| <button | |
| key={tab.id} | |
| type="button" |
| role="tab" | ||
| aria-selected={tab.active ? "true" : "false"} | ||
| tabIndex={tab.active ? 0 : -1} |
There was a problem hiding this comment.
aria-selected is being passed as the strings "true"/"false"; in React this should be a boolean so the attribute is correctly typed and consistent with other ARIA props. Also, if no tab is marked active, all tabs will end up with tabIndex={-1} and none will be reachable by keyboard—consider a fallback that makes the first tab focusable when there is no active tab.
| role="tab" | ||
| aria-selected={tab.active ? "true" : "false"} | ||
| tabIndex={tab.active ? 0 : -1} | ||
| onClick={() => onTabChange?.(tab.id)} |
There was a problem hiding this comment.
After adding role="tab", the ARIA tabs pattern expects keyboard interaction (e.g., arrow keys/Home/End to move focus between tabs) rather than relying only on Tab/Shift+Tab. Consider adding an onKeyDown handler to implement roving focus and activation behavior, or omit role="tab" if that interaction isn’t intended.
| </button> | ||
| </div> | ||
| {isOpen && <div className="px-4 py-3">{children}</div>} | ||
| {isOpen && <div id={contentId} className="px-4 py-3">{children}</div>} |
There was a problem hiding this comment.
aria-controls points to contentId, but the controlled element is conditionally rendered ({isOpen && ...}), so when collapsed the id referenced by aria-controls doesn’t exist in the DOM. For better AT support, keep the content container rendered with a stable id and toggle visibility via hidden/aria-hidden (and/or CSS), rather than removing it entirely.
| {isOpen && <div id={contentId} className="px-4 py-3">{children}</div>} | |
| <div | |
| id={contentId} | |
| className="px-4 py-3" | |
| hidden={!isOpen} | |
| aria-hidden={!isOpen} | |
| > | |
| {children} | |
| </div> |
| <button | ||
| onClick={() => setIsOpen(!isOpen)} | ||
| className="text-wiki-link text-sm hover:underline" | ||
| aria-expanded={isOpen} | ||
| aria-controls={contentId} | ||
| aria-label={isOpen ? `Hide ${title}` : `Show ${title}`} | ||
| > | ||
| [{isOpen ? "hide" : "show"}] | ||
| </button> | ||
| </div> | ||
| {isOpen && <div className="px-4 py-3">{children}</div>} | ||
| {isOpen && <div id={contentId} className="px-4 py-3">{children}</div>} |
There was a problem hiding this comment.
Consider adding landmark semantics to the collapsible content: when expanded, the content container can use role="region" and aria-labelledby pointing at an id on the toggle button (or title) so screen readers can identify what the region contains. Right now only aria-controls is set, but the panel itself has no accessible name/relationship back to the control.
💡 What: Added
role="tablist",role="tab",aria-selectedandtabIndexattributes toWikiTabs, and addeduseIdfor uniquearia-controlsmapping onWikiCollapsible.🎯 Why: Makes interactive collapsible widgets and tabs much more intuitive for screen reader users by properly associating toggles with their respective content panels, and defining appropriate widget roles.
♿ Accessibility: Improves screen reader context, keyboard navigation structure, and addresses missing structural roles for tab components.
PR created automatically by Jules for task 3307602881622537608 started by @aicoder2009