Skip to content

fix: support Space key activation - #454

Open
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/space-key-activation
Open

fix: support Space key activation#454
nrps9909 wants to merge 1 commit into
react-component:masterfrom
nrps9909:codex/space-key-activation

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown

Summary

  • activate enabled collapse headers with Space as well as Enter
  • prevent the Space default action so keyboard activation does not scroll the page
  • keep disabled headers inert for both activation keys

Verification

  • the exact-base regression passed the existing 94 cases but failed when Space neither toggled the panel nor prevented its default action
  • the fixed repository passes 95 tests and 1 snapshot
  • TypeScript, focused ESLint, Prettier, full ESM/CJS/declaration and Less compilation, and diff checks pass

Overlap audit

  • no open issue or PR targets Space activation
  • feat: accessibility improvements #363 adds structural accessibility relationships but leaves the current Enter-only keyboard handler unchanged

AI assistance disclosure: Codex was used to trace the keyboard path, audit open overlap, write the implementation and regression, and run validation. The failure and passing results above were verified directly on the exact base and this signed commit.

Summary by CodeRabbit

  • 新功能

    • 面板支持使用空格键切换展开/收起状态。
    • 兼容不同浏览器的 Enter 和空格键盘事件识别。
  • 问题修复

    • 修复禁用面板仍可能响应键盘操作的问题。
    • 键盘触发切换时会阻止默认行为,提升交互一致性。

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@nrps9909 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 Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 57e1c4d1-01bd-4152-a8dd-6290f757764f

📥 Commits

Reviewing files that changed from the base of the PR and between dcd0f78 and aed4afe.

📒 Files selected for processing (2)
  • src/Panel.tsx
  • tests/index.spec.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


Walkthrough

CollapsePanel 现在响应 Enter 和 Space。禁用面板不会响应这些按键。测试覆盖两种按键及禁用状态。

Changes

键盘面板切换

Layer / File(s) Summary
键盘切换行为与测试
src/Panel.tsx, tests/index.spec.tsx
onKeyDown 同时检测 Enter 和 Space,并要求面板未禁用。触发时调用 preventDefault()onItemClick。测试验证两种按键的切换结果,以及禁用面板不切换。

Estimated code review effort: 2 (简单) | ~10 分钟

Merge Risk: ⚪ Minimal · up to aed4a

This localized keyboard-activation change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Poem

小兔按下 Enter,面板轻轻开
Space 跳进来,状态随之改
禁用门关好,按键不乱来
测试灯亮起,结果排成排
代码拍拍耳朵,安心回窝睡

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了主要变更:为折叠面板支持 Space 键激活。标题简洁、明确,并符合提交历史中的可读性要求。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.

✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

1 participant