Skip to content

fix: prevent IME enter from submitting issue comments#8915

Open
wang2032 wants to merge 1 commit intomakeplane:previewfrom
wang2032:bug/comment
Open

fix: prevent IME enter from submitting issue comments#8915
wang2032 wants to merge 1 commit intomakeplane:previewfrom
wang2032:bug/comment

Conversation

@wang2032
Copy link
Copy Markdown

@wang2032 wang2032 commented Apr 20, 2026

Description

This PR fixes an issue where pressing Enter while composing Chinese text with an IME in issue comments would submit the comment immediately instead of confirming the composition.

Changes included:

  • Added IME composition state detection in the comment creation component
  • Added IME composition state detection in the comment edit form
  • Added composition state checks in the editor Enter key extension
  • Introduced a shared isComposingKeyboardEvent helper for IME keyboard event handling

This ensures that Enter confirms the current Chinese input first, and only submits the comment when composition is finished.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

N/A

Test Scenarios

  • Verified issue comment creation no longer submits when pressing Enter during Chinese IME composition
  • Verified issue comment editing no longer submits when pressing Enter during Chinese IME composition
  • Verified comment submission still works normally when pressing Enter after composition is completed
  • Verified existing modifier behavior such as Shift+Enter is unaffected

References

Closes #8913

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where comment submissions could be triggered unintentionally while using input methods with text composition (e.g., IME for Asian languages). The Enter key is now properly ignored during active composition to prevent accidental submissions.

- 在评论创建组件中添加输入法组合状态检测
- 在评论编辑表单中添加输入法组合状态检测
- 在编辑器扩展中添加组合输入状态检查
- 新增 isComposingKeyboardEvent 辅助函数处理输入法事件
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 20, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

The 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

Cohort / File(s) Summary
Keyboard Helper
apps/web/core/helpers/keyboard.ts
Added new exported helper function isComposingKeyboardEvent that detects IME composition events by checking event.isComposing property or keyCode === 229.
Comment Components
apps/web/core/components/comments/card/edit-form.tsx, apps/web/core/components/comments/comment-create.tsx
Added guard checks using the new helper to early-return from onKeyDown handlers when composition is active, preventing Enter-to-submit logic from firing during IME input.
Editor Extension
packages/editor/src/core/extensions/enter-key.ts
Added composition guard in the Enter keyboard shortcut to suppress key handling when editor.view.composing is true, allowing other Enter behaviors to remain unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 When fingers dance with language east,
And Enter keys compose their feast,
A helper hops with wisdom keen—
"Wait while typing!" it foresees.
No premature sends, clean and serene! 🌸

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preventing IME Enter from submitting comments, which aligns with the primary objective of the changeset.
Linked Issues check ✅ Passed The PR successfully addresses issue #8913 by implementing IME composition state detection across comment creation, editing, and editor components to prevent premature submission.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the IME composition issue; no unrelated modifications were introduced outside the stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description is comprehensive and well-structured, including all required template sections with clear explanations of the IME composition fix.

✏️ 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

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

@sophyphreak
Copy link
Copy Markdown

Please merge this.

@wang2032
Copy link
Copy Markdown
Author

请合并此条目。

A reviewer without write permission approved that I could not merge

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 isComposingKeyboardEvent helper 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.

Comment on lines +1 to +2
export const isComposingKeyboardEvent = (event: Pick<KeyboardEvent, "isComposing" | "keyCode">) =>
event.isComposing || event.keyCode === 229;
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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.

[bug]: When commenting on each issue, if it is in Chinese, pressing enter while typing will send it directly.

4 participants