Skip to content

🎨 Palette: Add ARIA bindings to WikiCollapsible#44

Open
aicoder2009 wants to merge 2 commits intomainfrom
palette-a11y-collapsible-5895627693753947285
Open

🎨 Palette: Add ARIA bindings to WikiCollapsible#44
aicoder2009 wants to merge 2 commits intomainfrom
palette-a11y-collapsible-5895627693753947285

Conversation

@aicoder2009
Copy link
Copy Markdown
Owner

🎨 Palette: Improved accessibility of the WikiCollapsible component by adding proper ARIA bindings.

💡 What: Added React's useId to generate a unique ID for the collapsible content div, and linked the toggle <button> using aria-controls and aria-expanded attributes.
🎯 Why: Custom interactive elements like collapsibles and tabs require explicit ARIA attributes to be properly announced and navigable by screen readers. The useId hook 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

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 <[email protected]>
Copilot AI review requested due to automatic review settings April 30, 2026 11:24
@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.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 30, 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:10pm

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 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 via aria-controls.
  • Add aria-expanded to 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.

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

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

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

Copilot uses AI. Check for mistakes.
@@ -22,11 +23,13 @@ export function WikiCollapsible({
<button
onClick={() => setIsOpen(!isOpen)}
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

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

Suggested change
onClick={() => setIsOpen(!isOpen)}
onClick={() => setIsOpen((v) => !v)}

Copilot uses AI. Check for mistakes.
</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 30, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
{isOpen && <div id={contentId} className="px-4 py-3">{children}</div>}
<div id={contentId} className="px-4 py-3" hidden={!isOpen}>
{children}
</div>

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