fix: prevent IME enter from submitting issue comments#8915
fix: prevent IME enter from submitting issue comments#8915wang2032 wants to merge 1 commit intomakeplane:previewfrom
Conversation
- 在评论创建组件中添加输入法组合状态检测 - 在评论编辑表单中添加输入法组合状态检测 - 在编辑器扩展中添加组合输入状态检查 - 新增 isComposingKeyboardEvent 辅助函数处理输入法事件
📝 WalkthroughWalkthroughThe changes add a new helper function to detect IME composition events and apply guards across multiple keyboard event handlers—in comment edit forms, comment creation containers, and the editor extension—to prevent Enter key submission during text composition. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Please merge this. |
A reviewer without write permission approved that I could not merge |
There was a problem hiding this comment.
Pull request overview
Fixes accidental issue-comment submission when pressing Enter during IME (e.g., Chinese) text composition by ensuring Enter is ignored while composition is active.
Changes:
- Added composition-state guard to the editor Enter-key extension to avoid triggering submit during IME composition.
- Added a shared
isComposingKeyboardEventhelper and used it in comment create/edit keyboard handlers. - Updated comment create and edit form keydown handlers to bail out during composition.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/editor/src/core/extensions/enter-key.ts | Prevents the editor’s Enter shortcut from firing while IME composition is active. |
| apps/web/core/helpers/keyboard.ts | Introduces a reusable helper for detecting IME-composing keyboard events. |
| apps/web/core/components/comments/comment-create.tsx | Avoids submit-on-Enter during IME composition while creating comments. |
| apps/web/core/components/comments/card/edit-form.tsx | Avoids submit-on-Enter during IME composition while editing comments. |
| export const isComposingKeyboardEvent = (event: Pick<KeyboardEvent, "isComposing" | "keyCode">) => | ||
| event.isComposing || event.keyCode === 229; |
There was a problem hiding this comment.
This new helper file is missing the standard copyright/SPDX header that appears at the top of other source files in this repo (e.g. apps/web/core/components/comments/comment-create.tsx:1-5). Please add the same header block here for consistency and licensing compliance.
Description
This PR fixes an issue where pressing
Enterwhile composing Chinese text with an IME in issue comments would submit the comment immediately instead of confirming the composition.Changes included:
Enterkey extensionisComposingKeyboardEventhelper for IME keyboard event handlingThis ensures that
Enterconfirms the current Chinese input first, and only submits the comment when composition is finished.Type of Change
Screenshots and Media (if applicable)
N/A
Test Scenarios
Enterduring Chinese IME compositionEnterduring Chinese IME compositionEnterafter composition is completedShift+Enteris unaffectedReferences
Closes #8913
Summary by CodeRabbit