fix: Prevent IME-exiting Enter press from sending message on Safari (#2175)
authorMari <reya.git@reya.zone>
Thu, 25 Sep 2025 03:35:42 +0000 (23:35 -0400)
committerGitHub <noreply@github.com>
Thu, 25 Sep 2025 03:35:42 +0000 (09:05 +0530)
commit867a47218a7150b8c1dd652b815136a50813c087
treefd88092152a65b3213532eca015360400842f1b5
parentafc251aa7cafa0d11f531521f1c96ac560b85bde
fix: Prevent IME-exiting Enter press from sending message on Safari (#2175)

On most browsers, pressing Enter to end IME composition produces this
sequence of events:
* keydown (keycode 229, key Processing/Unidentified, isComposing true)
* compositionend
* keyup (keycode 13, key Enter, isComposing false)

On Safari, the sequence is different:
* compositionend
* keydown (keycode 229, key Enter, isComposing false)
* keyup (keycode 13, key Enter, isComposing false)

This causes Safari users to mistakenly send their messages when they
press Enter to confirm their choice in an IME.

The workaround is to treat the next keydown with keycode 229 as if it
were part of the IME composition period if it occurs within a short time
of the compositionend event.

Fixes #2103, but needs confirmation from a Safari user.
src/app/features/room/RoomInput.tsx
src/app/features/room/message/MessageEditor.tsx
src/app/hooks/useComposingCheck.ts [new file with mode: 0644]
src/app/pages/App.tsx
src/app/state/lastCompositionEnd.ts [new file with mode: 0644]