Skip to content

fix: clear enter lock when select is disabled - #1248

Open
dogledogle wants to merge 1 commit into
react-component:masterfrom
dogledogle:fix/clear-enter-lock-on-disable
Open

fix: clear enter lock when select is disabled#1248
dogledogle wants to merge 1 commit into
react-component:masterfrom
dogledogle:fix/clear-enter-lock-on-disable

Conversation

@dogledogle

@dogledogle dogledogle commented Aug 21, 2026

Copy link
Copy Markdown

修复 Select 在异步更新过程中被设为 disabled 后,Enter 键状态未正确重置的问题。

当用户通过搜索并按 Enter 选择选项时,如果 onChange 中立即将 Select 设为 disabled,输入框可能不会触发后续的 keyupblur 事件,导致 Enter 锁状态残留。重新启用 Select 后,用户需要按两次 Enter 才能完成下一次选择。

本次修改会在 Select 进入 disabled 状态时主动清理 Enter 锁,并新增回归测试,确保连续搜索选择只需按一次 Enter。

相关 issue:#51716

Summary by CodeRabbit

  • Bug Fixes

    • 修复 Select 在 Enter 键操作过程中被禁用后,可能残留键盘锁定状态的问题。
    • 重新启用后,可继续正常搜索并按 Enter 依次选择选项。
  • Tests

    • 增加禁用、重新启用及后续选择流程的测试覆盖。

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

@dogledogle 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 21, 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: 4281db18-5a64-4e34-974b-98a8f5930661

📥 Commits

Reviewing files that changed from the base of the PR and between 29e9dda and 6449ac5.

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

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


Walkthrough

Select 进入 disabled 状态时,组件会清理 Enter 键锁定状态。新增回归测试验证中断 keyup 后重新启用组件仍可连续键盘选择。

Changes

Select 键盘交互

Layer / File(s) Summary
禁用状态清理与回归验证
src/BaseSelect/index.tsx, tests/Select.test.tsx
禁用状态变化时将 keyLockRef.current 重置为 false。回归测试覆盖搜索、Enter 选择、禁用后重新启用,以及 [3, 2, 1]onChange 调用顺序。

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

Merge Risk: ⚪ Minimal · up to 6449a

This is a localized fix for clearing stale Enter-key state when a Select becomes disabled, with a regression test added; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: afc163, qdyanbing

Poem

小兔按下 Enter 键,
锁定状态随禁用清。
键起未至也无妨,
重启搜索选项明。
三二一声回调响。

🚥 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 标题准确概括了在 Select 禁用时清除 Enter 键锁定状态这一主要变更,内容简洁且明确。
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 files.
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.
✨ 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