diff options
author | Hailey <me@haileyok.com> | 2024-05-21 13:37:16 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-21 13:37:16 -0700 |
commit | cbfb69dd1530319a8a5ad9807778015e38f3c228 (patch) | |
tree | c38faaeb7c9243b25772e4f134a8dfc2059409d9 /src | |
parent | 866b0b9121da0794e00b44bfee559364837c26d4 (diff) | |
download | voidsky-cbfb69dd1530319a8a5ad9807778015e38f3c228.tar.zst |
[🐴] Support Japanese (et al.) IME in message input on web (#4159)
* support japanese et al. IME * update comment * nit
Diffstat (limited to 'src')
-rw-r--r-- | src/screens/Messages/Conversation/MessageInput.web.tsx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/screens/Messages/Conversation/MessageInput.web.tsx b/src/screens/Messages/Conversation/MessageInput.web.tsx index dd7c4f685..3e78608a7 100644 --- a/src/screens/Messages/Conversation/MessageInput.web.tsx +++ b/src/screens/Messages/Conversation/MessageInput.web.tsx @@ -26,6 +26,7 @@ export function MessageInput({ const [message, setMessage] = React.useState(getDraft) const inputStyles = useSharedInputStyles() + const isComposing = React.useRef(false) const [isFocused, setIsFocused] = React.useState(false) const [isHovered, setIsHovered] = React.useState(false) @@ -44,13 +45,15 @@ export function MessageInput({ const onKeyDown = React.useCallback( (e: React.KeyboardEvent<HTMLTextAreaElement>) => { + // Don't submit the form when the Japanese or any other IME is composing + if (isComposing.current) return if (e.key === 'Enter') { if (e.shiftKey) return e.preventDefault() onSubmit() } }, - [onSubmit], + [onSubmit, isComposing], ) const onChange = React.useCallback( @@ -102,6 +105,12 @@ export function MessageInput({ autoFocus={true} onFocus={() => setIsFocused(true)} onBlur={() => setIsFocused(false)} + onCompositionStart={() => { + isComposing.current = true + }} + onCompositionEnd={() => { + isComposing.current = false + }} onChange={onChange} onKeyDown={onKeyDown} /> |