Skip to content

Fix Japanese IME input handling in message composer #30324

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

sojin25
Copy link

@sojin25 sojin25 commented Jul 16, 2025

This commit addresses input issues with Japanese IME (Input Method Editor) where pressing Enter to confirm IME suggestions would create unwanted line breaks instead of properly confirming the input.

Changes include:

  • Enhanced platform detection for proper cross-platform IME support
  • Improved composition event handling for Japanese input
  • Strengthened isComposing() method with platform-specific checks
  • Added proper handling for composition confirmation events
  • Platform-specific timing adjustments for input processing

Fixes IME input issues on:

  • macOS Safari
  • Windows/Electron environments
  • Other modern browsers

🤖 Generated with Claude Code

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • I have licensed the changes to Element by completing the Contributor License Agreement (CLA)

This commit addresses input issues with Japanese IME (Input Method
Editor) where pressing Enter to confirm IME suggestions would create
unwanted line breaks instead of properly confirming the input.

Changes include:
- Enhanced platform detection for proper cross-platform IME support
- Improved composition event handling for Japanese input
- Strengthened isComposing() method with platform-specific checks
- Added proper handling for composition confirmation events
- Platform-specific timing adjustments for input processing

Fixes IME input issues on:
- macOS Safari
- Windows/Electron environments
- Other modern browsers

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@sojin25 sojin25 requested a review from a team as a code owner July 16, 2025 02:05
@CLAassistant
Copy link

CLAassistant commented Jul 16, 2025

CLA assistant check
All committers have signed the CLA.

@github-actions github-actions bot added the Z-Community-PR Issue is solved by a community member's PR label Jul 16, 2025
Copy link
Member

@florianduros florianduros left a comment

Choose a reason for hiding this comment

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

Hi! Thanks for the contribution.
I'm really conflicted about the quality of the PR generated by an LLM....

Comment on lines +157 to +168
private detectPlatform(): IPlatformInfo {
const ua = navigator.userAgent.toLowerCase();
const platform = navigator.platform || "";

return {
isElectron: !!(window as any).electron || ua.includes('electron'),
isWindows: ua.includes('win') || platform.includes('Win'),
isMac: ua.includes('mac') || platform.includes('Mac'),
isSafari: ua.includes("safari/") && !ua.includes("chrome/"),
};
}

Copy link
Member

Choose a reason for hiding this comment

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

This is mixing platform, browser etc
Why do we need to detect windows and macos?

Comment on lines +296 to +297
// IME確定後の入力イベントをプラットフォームに応じて処理

Copy link
Member

Choose a reason for hiding this comment

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

Please keep the previous comment. Also the comments should be in english

Comment on lines +305 to +307
} else if (this.platformInfo.isElectron) {
// Electronでは確実に非同期実行
setTimeout(triggerInput, 0);
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to do that?

Comment on lines +315 to +325
// IME composition状態の統合的な判定
const nativeEvent = event.nativeEvent;
const isNativeComposing = nativeEvent && nativeEvent.isComposing;

// プラットフォーム固有の追加チェック
const isPlatformSpecificComposing = (
(this.platformInfo.isMac && this.platformInfo.isSafari && event.which === 229) ||
((this.platformInfo.isWindows || this.platformInfo.isElectron) && event.which === 229)
);

return !!(this.isIMEComposing || isNativeComposing || isPlatformSpecificComposing);
Copy link
Member

Choose a reason for hiding this comment

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

Keep the original comments and please explain why is it needed

Comment on lines +404 to +405
// IME composition中は確定イベント以外を無視
if (this.isIMEComposing && event.inputType !== "insertCompositionText") {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

return;
}

Copy link
Member

Choose a reason for hiding this comment

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

Unneeded space change

Comment on lines +507 to +523
// IME composition中は全てのキーイベントを無視
if (this.isComposing(event)) {
return;
}

// プラットフォーム固有のIME処理
if (this.platformInfo.isMac && this.platformInfo.isSafari && event.which === 229) {
// Safariの追加のkeyDownを無視
event.stopPropagation();
return;
}

// Windows/ElectronでのIMEキーコード229処理
if ((this.platformInfo.isWindows || this.platformInfo.isElectron) && event.which === 229) {
// Windows IMEのキーコード229を適切に処理
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants