Skip to content

fix(a11y): toggle panel with Space and ignore keys from nested controls - #459

Closed
droduit wants to merge 1 commit into
react-component:masterfrom
droduit:fix/a11y-space-key
Closed

droduit wants to merge 1 commit into
react-component:masterfrom
droduit:fix/a11y-space-key

Conversation

@droduit

@droduit droduit commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Related issue

Fixes ant-design/ant-design#59684 (Space key part; aria-controls was added in #458).

Takes over #457, which has been conflicting with master and failing Codecov for several days. The original author is credited as co-author of the commit. Thanks @feritcemkahraman!

Problem

The panel header has role="button" (or role="tab" in accordion mode), but it only toggles on Enter. A button must also respond to Space (WCAG 2.2 SC 2.1.1 Keyboard).

Solution

  • Panel: Space toggles the panel, like Enter. preventDefault() keeps the page from scrolling, like a native button.
  • Key events coming from nested controls (for example a <button> in extra) are ignored by the header, so Space and Enter keep their own action on those controls.
  • Only e.key === ' ' is checked: React already normalizes key, so the legacy 'Spacebar' / which fallbacks from fix: support Space key to toggle panel and prevent default scroll #457 are not needed (they were the uncovered lines in Codecov).

Tests

  • should toggle panel when press space: Space toggles the panel, the default action is prevented, and a disabled header ignores it.
  • should leave keyboard events on a nested extra button to the button: Space and Enter on a nested button do not toggle the panel.

npm test (102 passed), npm run lint and npm run tsc pass.

The header (role="button" or "tab") only toggled on Enter (WCAG 2.2 SC
2.1.1). Space now toggles it without scrolling the page. Key events from
nested controls, such as a button in `extra`, are left to those controls.

Based on react-component#457.

ref ant-design/ant-design#59684

Co-authored-by: Ferit Cem <92086876+feritcemkahraman@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 28, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.23%. Comparing base (ccae2e7) to head (c1f51a8).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #459      +/-   ##
==========================================
+ Coverage   99.20%   99.23%   +0.03%     
==========================================
  Files           5        5              
  Lines         126      131       +5     
  Branches       46       48       +2     
==========================================
+ Hits          125      130       +5     
  Misses          1        1              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@droduit droduit closed this Oct 28, 2026
@droduit

droduit commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Closing in favor of #457, whose author is actively updating it (the conflict was resolved today). Happy to reopen this one if #457 stalls.

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.

Collapse: header (role="button") does not toggle with Space key and has no aria-controls

1 participant