-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Add IME judgment #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add IME judgment #71
Conversation
Important Review skippedReview was skipped due to path filters ⛔ Files ignored due to path filters (1)
CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including You can disable this status message by setting the """ Walkthrough本次更改主要针对 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TextArea
participant IME
participant App
User->>TextArea: 按下任意键
TextArea->>IME: 检查是否为组合输入
alt 组合输入中 (isComposing = true)
User->>TextArea: 按下 Enter
TextArea--xApp: 不触发 onPressEnter
else 组合输入结束 (isComposing = false)
User->>TextArea: 按下 Enter
TextArea->>App: 触发 onPressEnter
end
Assessment against linked issues
Poem
✨ Finishing Touches🧪 Generate 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
package.json
(1 hunks)src/TextArea.tsx
(1 hunks)tests/index.spec.tsx
(1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
tests/index.spec.tsx
[error] 385-385: Don't focus the test.
The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.
(lint/suspicious/noFocusedTests)
🔇 Additional comments (4)
package.json (1)
47-47
: 手动验证 @rc-component/[email protected] 的 IME 功能支持自动检查结果:
- npm 上已发布
@rc-component/[email protected]
- README.md 和 CHANGELOG.md 中未找到 “IME”、“composition” 或 “输入法” 相关说明
请手动确认该版本在 TextArea 或 Input 组件中的 IME 支持是否已正确实现,并在发布日志或源码中补充对应文档。
src/TextArea.tsx (1)
157-157
: IME 组合输入处理实现正确通过检查
!e.nativeEvent.isComposing
条件来避免在 IME 组合输入期间触发onPressEnter
回调,这个实现完全符合预期需求。使用标准的 DOM API 确保了跨浏览器的兼容性。tests/index.spec.tsx (2)
386-410
: IME 组合输入测试用例设计完善测试用例正确模拟了 IME 组合输入的完整流程:
- compositionStart 开始组合
- 带有 isComposing: true 的 Enter 键按下
- compositionUpdate 更新组合内容
- 验证 onPressEnter 未被调用
- compositionEnd 结束组合后的正常 Enter 键处理
这个测试完全覆盖了新功能的核心场景。
412-424
: 正常输入测试用例补充必要为 IME 功能添加正常输入场景的测试是很好的实践,确保新功能不会影响现有的正常输入行为。测试逻辑清晰且覆盖充分。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds IME handling for the Enter key to prevent onPressEnter from firing during composition, includes new tests for this behavior, and upgrades a dependency.
- Prevent onPressEnter during IME composition by checking
e.nativeEvent.isComposing
- Add tests verifying Enter is ignored during composition and fires after composition ends
- Bump
@rc-component/input
dependency to ~1.1.0
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/TextArea.tsx | Skip onPressEnter when nativeEvent.isComposing is true |
tests/index.spec.tsx | New tests for IME composition behavior around Enter key |
package.json | Upgrade @rc-component/input from ~1.0.0 to ~1.1.0 |
Comments suppressed due to low confidence (2)
src/TextArea.tsx:157
- [nitpick] Consider adding an inline comment explaining that the
!e.nativeEvent.isComposing
check preventsonPressEnter
from firing during IME composition, for future maintainers.
if (e.key === 'Enter' && onPressEnter && !e.nativeEvent.isComposing) {
package.json:47
- After bumping the dependency version in package.json, please update the corresponding lockfile (e.g., yarn.lock or package-lock.json) to ensure CI and local installs use the intended version.
"@rc-component/input": "~1.1.0",
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #71 +/- ##
=======================================
Coverage 99.03% 99.03%
=======================================
Files 3 3
Lines 208 208
Branches 64 64
=======================================
Hits 206 206
Misses 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
增加 IME 组合输入时候,Enter键判断调用
close ant-design/ant-design#54214
Summary by CodeRabbit
Bug Fixes
Tests
Chores