Skip to content

🎨 Palette: Accessible Collapsibles#39

Open
aicoder2009 wants to merge 2 commits intomainfrom
palette-accessible-collapsibles-4101924143864366512
Open

🎨 Palette: Accessible Collapsibles#39
aicoder2009 wants to merge 2 commits intomainfrom
palette-accessible-collapsibles-4101924143864366512

Conversation

@aicoder2009
Copy link
Copy Markdown
Owner

🎨 Palette: Accessible Collapsibles

💡 What: Added dynamic, unique ID generation using React's useId hook and mapped aria-expanded and aria-controls to the WikiCollapsible component'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

- 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]>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
opencitation Ready Ready Preview, Comment May 1, 2026 6:15pm

Copilot AI review requested due to automatic review settings April 29, 2026 12:05
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-expanded and aria-controls to the toggle button and apply the generated id to 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.

Comment on lines 23 to 28
<button
onClick={() => setIsOpen(!isOpen)}
className="text-wiki-link text-sm hover:underline"
aria-expanded={isOpen}
aria-controls={contentId}
>
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +26 to +36
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>
)}
Copy link

Copilot AI Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@aicoder2009 aicoder2009 closed this May 1, 2026
@aicoder2009 aicoder2009 reopened this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants