-
Notifications
You must be signed in to change notification settings - Fork 49
feat: Add IME judgment #125
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
Conversation
Walkthrough本次变更在 Input 组件的 Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant InputComponent
participant onPressEnter
User->>InputComponent: 开始组合输入 (compositionStart)
User->>InputComponent: 按下 Enter (isComposing = true)
InputComponent--x onPressEnter: 不触发回调
User->>InputComponent: 结束组合输入 (compositionEnd)
User->>InputComponent: 再次按下 Enter (isComposing = false)
InputComponent->>onPressEnter: 触发回调
Possibly related PRs
Suggested reviewers
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
src/Input.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. tests/index.test.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the config "prettier" to extend from. Please check that the name of the config is correct. The config "prettier" was referenced from the config file in "/.eslintrc.js". If you still have problems, please stop by https://eslint.org/chat/help to chat with the team. ✨ 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 (
|
|
解决什么问题? |
|
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: 0
🧹 Nitpick comments (1)
tests/index.test.tsx (1)
4-4: 删除未使用的导入
ElementType导入在文件中没有使用,应该删除以保持代码整洁。-import React, { ElementType } from 'react'; +import React from 'react';
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/Input.tsx(1 hunks)tests/index.test.tsx(2 hunks)
🔇 Additional comments (2)
src/Input.tsx (1)
163-168: IME组合输入判断逻辑正确!新增的
!e.nativeEvent.isComposing条件能够有效防止在输入法组合输入期间触发onPressEnter回调,这是处理IME输入的标准做法,实现符合预期。tests/index.test.tsx (1)
508-543: IME行为测试覆盖全面!新增的测试套件很好地覆盖了IME场景:
- 第一个测试准确模拟了IME组合过程中的事件序列,验证了在组合期间Enter键不会触发onPressEnter
- 第二个测试使用userEvent模拟真实的用户输入行为,确保正常情况下功能正常工作
测试用例设计合理,能够有效验证IME判断逻辑的正确性。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #125 +/- ##
==========================================
+ Coverage 97.66% 97.70% +0.04%
==========================================
Files 4 4
Lines 214 218 +4
Branches 78 84 +6
==========================================
+ Hits 209 213 +4
Misses 5 5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
增加 IME 组合输入时候,Enter键判断调用
Summary by CodeRabbit
Bug Fixes
Tests