Fixes issue where cursor would jump to the beginning of the input field after converting Japanese text and pressing Tab (#31432)

* Fix cursor position bug during IME composition

Add IME composition check to BasicMessageComposer.onKeyDown to prevent
cursor position issues when pressing Tab key immediately after Japanese
input conversion. This matches the behavior in SendMessageComposer and
EditMessageComposer.

Fixes issue where cursor would jump to the beginning of the input field
after converting Japanese text and pressing Tab.

* Add tests for IME composition keydown handling

- Add test to verify keydown events are ignored during IME composition
- Add test to verify keydown events are handled normally when not composing
- Tests ensure the fix for Japanese IME cursor position bug works correctly
This commit is contained in:
Hiroshi Shinaoka
2025-12-05 20:18:01 +09:00
committed by GitHub
parent 39fb67c201
commit 5607291f1e
2 changed files with 73 additions and 1 deletions

View File

@@ -482,6 +482,11 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
private onKeyDown = (event: React.KeyboardEvent): void => {
if (!this.editorRef.current) return;
// Ignore any keypress while doing IME compositions to prevent cursor position issues
// This matches the behavior in SendMessageComposer and EditMessageComposer
if (this.isComposing(event)) {
return;
}
if (this.isSafari && event.which == 229) {
// Swallow the extra keyDown by Safari
event.stopPropagation();