🎨 Palette: Add ARIA bindings to WikiCollapsible#44
Conversation
Added `useId` to generate unique IDs for `aria-controls` mapping on the WikiCollapsible component toggle, improving screen reader context and accessibility. 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 of the WikiCollapsible wiki UI component by adding ARIA bindings between the toggle button and the collapsible content, using React useId to avoid ID collisions across instances.
Changes:
- Add
useId-generated content ID and wire it to the toggle button viaaria-controls. - Add
aria-expandedto expose expanded/collapsed state to assistive tech. - Add a palette note documenting the accessibility pattern.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/components/wiki/wiki-collapsible.tsx | Adds useId and ARIA attributes to associate the toggle button with the collapsible content. |
| .jules/palette.md | Documents the accessibility learning/action for using useId + ARIA bindings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <button | ||
| onClick={() => setIsOpen(!isOpen)} | ||
| className="text-wiki-link text-sm hover:underline" | ||
| aria-expanded={isOpen} | ||
| aria-controls={contentId} |
There was a problem hiding this comment.
The toggle <button> is missing type="button". In this codebase, wiki UI buttons typically set an explicit type to avoid accidental form submission when the component is rendered inside a <form> (e.g., src/components/wiki/wiki-dropdown.tsx:40-46, src/components/wiki/barcode-scanner.tsx:91-97).
| @@ -22,11 +23,13 @@ export function WikiCollapsible({ | |||
| <button | |||
| onClick={() => setIsOpen(!isOpen)} | |||
There was a problem hiding this comment.
The click handler uses setIsOpen(!isOpen), which can read a stale value under React concurrent updates. Use a functional state update (setIsOpen(v => !v)) to ensure correctness and match existing patterns in wiki components (e.g., setOpen((v) => !v) in src/components/wiki/wiki-dropdown.tsx:42).
| onClick={() => setIsOpen(!isOpen)} | |
| onClick={() => setIsOpen((v) => !v)} |
| </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 always references contentId, but the controlled element is only conditionally rendered ({isOpen && ...}), so when collapsed the DOM contains an IDREF to a non-existent element. For valid/robust ARIA (and better screen reader support), keep the content container in the DOM with a stable id and toggle its visibility (e.g., via hidden/aria-hidden/CSS) instead of unmounting it.
| {isOpen && <div id={contentId} className="px-4 py-3">{children}</div>} | |
| <div id={contentId} className="px-4 py-3" hidden={!isOpen}> | |
| {children} | |
| </div> |
🎨 Palette: Improved accessibility of the
WikiCollapsiblecomponent by adding proper ARIA bindings.💡 What: Added React's
useIdto generate a unique ID for the collapsible contentdiv, and linked the toggle<button>usingaria-controlsandaria-expandedattributes.🎯 Why: Custom interactive elements like collapsibles and tabs require explicit ARIA attributes to be properly announced and navigable by screen readers. The
useIdhook ensures that if multiple collapsibles are rendered on the same page, there will be no ID collisions.♿ Accessibility: Screen readers will now correctly announce the expanded/collapsed state and structurally associate the toggle button with its content block.
PR created automatically by Jules for task 5895627693753947285 started by @aicoder2009