🎨 Palette: Accessible Collapsibles#39
Conversation
- Utilized `useId` to generate a unique ID for the collapsible content. - Added `aria-expanded` and `aria-controls` to the toggle button. - Mapped the unique ID to the content container's `id`. - Added learning regarding accessible interactive widgets to `.jules/palette.md`. Co-authored-by: aicoder2009 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 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. |
There was a problem hiding this comment.
Pull request overview
Improves the accessibility of the WikiCollapsible UI component by introducing unique IDs for the collapsible content and wiring the toggle button’s ARIA attributes to that content, reducing ID-collision risk when multiple collapsibles are present.
Changes:
- Add
useId()-based unique ID generation for the collapsible content container. - Add
aria-expandedandaria-controlsto the toggle button and apply the generatedidto the content. - Add a short Palette note documenting the accessibility learning.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/components/wiki/wiki-collapsible.tsx | Adds useId and ARIA mappings between the toggle button and collapsible content. |
| .jules/palette.md | Documents the accessibility rationale and guidance for using useId with aria-controls. |
💡 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 is missing type="button". In this codebase, wiki UI buttons typically specify type="button" to avoid accidental form submission when the component is used inside a (e.g., src/components/wiki/wiki-dropdown.tsx, src/components/wiki/barcode-scanner.tsx).
| aria-expanded={isOpen} | ||
| aria-controls={contentId} | ||
| > | ||
| [{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.
aria-controls points at contentId, but the controlled element is only rendered when isOpen is true. When collapsed, the DOM no longer contains an element with that id, so assistive tech may not be able to resolve the relationship. Consider always rendering the content container with a stable id and toggling visibility via hidden/CSS (and optionally role="region" + aria-labelledby) instead of unmounting it.
🎨 Palette: Accessible Collapsibles
💡 What: Added dynamic, unique ID generation using React's
useIdhook and mappedaria-expandedandaria-controlsto theWikiCollapsiblecomponent's toggle button.🎯 Why: To ensure correct screen reader context and prevent ID collisions when multiple collapsibles are rendered on the same page.
♿ Accessibility: The toggle button now correctly informs screen readers about its expanded state and the specific content it controls.
PR created automatically by Jules for task 4101924143864366512 started by @aicoder2009