Skip to content

fix: preserve item click on keyboard activation - #395

Merged
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/keyboard-item-click
Aug 27, 2026
Merged

fix: preserve item click on keyboard activation#395
yoyo837 merged 1 commit into
react-component:masterfrom
nrps9909:codex/keyboard-item-click

Conversation

@nrps9909

@nrps9909 nrps9909 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • route Enter and Space activation through the Step's existing click path
  • preserve both the item-level onClick and the Steps-level change callback for keyboard users
  • prevent the Space key from scrolling the page while activating a Step
  • extend the keyboard regression to cover both keys, both callbacks, and canceled defaults

Problem

A clickable Step exposes role="button", but its keyboard handler called only the parent onClick(index) path. Mouse activation also calls the public item-level onClick, so the same Step behaved differently depending on input method. Space activation additionally left its page-scroll default intact.

The exact-base regression invoked Enter and Space and received two parent changes but zero item callbacks. The fix reuses currentTarget.click(), keeping the existing click behavior as the single activation path.

Validation

  • npm test: 2 suites, 24 tests, 13 snapshots
  • npm run tsc
  • npm run lint
  • Prettier check
  • npm run compile: ESM, CJS, declarations, Less
  • git diff --check
  • all open PR changed-file lists audited with no overlap

AI assistance disclosure: Codex was used to trace the input-specific callback paths, write and run the failing regression, audit open-PR file overlap, and draft this description. I verified the exact-base failure and all fixed-head validation locally.

Summary by CodeRabbit

  • Bug 修复

    • 改进步骤项的键盘操作,支持使用 Enter 和空格键触发点击。
    • 处理键盘事件时阻止默认行为,避免意外操作。
    • 确保键盘触发与鼠标点击一致,同时执行相关点击回调。
  • 测试

    • 增加对键盘事件默认行为及点击回调的覆盖。

@vercel

vercel Bot commented Aug 27, 2026

Copy link
Copy Markdown

@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

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: d752251f-b440-4bad-92d3-4091d37b4241

📥 Commits

Reviewing files that changed from the base of the PR and between e1a4d01 and c0f71de.

📒 Files selected for processing (2)
  • src/Step.tsx
  • tests/index.test.tsx

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


Walkthrough

Step 组件改用 e.key 处理 Enter 和空格键。处理器会阻止默认行为并触发元素点击,使 onItemClickonClick 按统一路径执行。测试覆盖两种按键及其回调结果。

Changes

键盘事件流

Layer / File(s) Summary
更新 Step 键盘处理
src/Step.tsx
移除 KeyCode 依赖。组件使用 e.key 识别 Enter 和空格键,调用 preventDefault(),再触发当前元素的 click 事件。
验证键盘回调行为
tests/index.test.tsx
测试构造 Enter 和空格键事件,并验证默认行为被阻止、onChange 调用两次、onItemClick 调用两次。

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to c0f71

This localized change preserves item clicks and parent callbacks for Enter and Space activation while preventing Space from scrolling the page. No actionable merge-blocking risk remains after normal checks and review.

Poem

小兔敲下 Enter 键,
空格随后也响应。
默认行为轻轻停,
点击路径回调同。
测试记录两声响,
胡萝卜旁代码香。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题“fix: preserve item click on keyboard activation”准确概括了键盘激活时保留项目点击处理的主要变更,内容简洁且与改动直接相关。
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.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e1a4d01) to head (c0f71de).

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #395   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines           99        99           
  Branches        38        38           
=========================================
  Hits            99        99           

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

@yoyo837
yoyo837 merged commit a880d11 into react-component:master Aug 27, 2026
9 of 10 checks passed
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