Skip to content

fix: skip flushInputValue and onPressEnter during IME composition#731

Open
Hualalala741 wants to merge 1 commit intoreact-component:masterfrom
Hualalala741:fix/ime-composition-enter
Open

fix: skip flushInputValue and onPressEnter during IME composition#731
Hualalala741 wants to merge 1 commit intoreact-component:masterfrom
Hualalala741:fix/ime-composition-enter

Conversation

@Hualalala741
Copy link
Copy Markdown

@Hualalala741 Hualalala741 commented May 1, 2026

composition 未结束前不应执行 flushInputValue 和 onPressEnter,否则受控value会与输入框不同步。

  • 问题:
2E13617B-C424-4717-8940-B77FB35DFA6B
  • 修改后:
2026-05-01 03 24 29

Summary by CodeRabbit

发布说明

  • Bug Fixes

    • 改进了输入法(IME)组合状态下的Enter键行为处理,确保Enter键在输入法活动期间被正确抑制。
  • Tests

    • 新增键盘/输入法相关测试用例,验证Enter键和输入法组合状态的交互行为。

@vercel
Copy link
Copy Markdown

vercel Bot commented May 1, 2026

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

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c73fd669-330f-4a83-be2b-77203793e237

📥 Commits

Reviewing files that changed from the base of the PR and between 88c6a43 and 071c671.

📒 Files selected for processing (2)
  • src/InputNumber.tsx
  • tests/keyboard.test.tsx

概述

优化了 InputNumber 组件的 Enter 键处理逻辑,将多个条件检查合并为单一判断,同时新增两个测试用例以验证在 IME 输入法组合状态下 Enter 键行为的正确性。

变更

群组/文件 摘要
代码简化
src/InputNumber.tsx
合并 onKeyDown 处理器中 Enter 分支的两个条件检查为单一条件 (key === 'Enter' && !compositionRef.current),简化逻辑流程。
测试覆盖
tests/keyboard.test.tsx
新增两个 IME 输入法测试用例:验证激活输入法组合时 onPressEnter 不被触发,以及组合结束后恢复正常;确保组合期间 onChange 和值刷新不执行。

建议的审阅者

  • zombieJ

预估代码审阅工作量

🎯 2 (Simple) | ⏱️ ~12 分钟

🐰 Enter 键按下又如何,
IME 正忙碌着呢喔,
条件合并变简洁,
测试守护新逻辑,
输入法世界更和谐!

🚥 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 PR标题清晰准确地概括了主要改动:在IME组合过程中跳过flushInputValue和onPressEnter的执行,与代码改动完全对应。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request modifies the InputNumber component to prevent triggering onPressEnter and flushing the input value when the Enter key is pressed during IME composition. It also adds comprehensive unit tests to verify this behavior and ensure that these actions only occur after composition has ended. I have no feedback to provide.

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