From 9f47fad3057c1a3b591e59bc86c814b3482833cc Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 24 Sep 2019 15:32:30 +0200 Subject: [PATCH] ignore keydown events while doing IME composition --- src/components/views/rooms/BasicMessageComposer.js | 2 ++ src/components/views/rooms/EditMessageComposer.js | 3 +++ src/components/views/rooms/SendMessageComposer.js | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index 14c850b9a3..40142d4436 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -177,6 +177,8 @@ export default class BasicMessageEditor extends React.Component { }, 0); } + shouldIgnoreKeyDownEvents() { + return this._isIMEComposing; } _onPaste = (event) => { diff --git a/src/components/views/rooms/EditMessageComposer.js b/src/components/views/rooms/EditMessageComposer.js index a1d6fa618f..c744711f61 100644 --- a/src/components/views/rooms/EditMessageComposer.js +++ b/src/components/views/rooms/EditMessageComposer.js @@ -127,6 +127,9 @@ export default class EditMessageComposer extends React.Component { } _onKeyDown = (event) => { + if (this._editorRef.shouldIgnoreKeyDownEvents()) { + return; + } if (event.metaKey || event.altKey || event.shiftKey) { return; } diff --git a/src/components/views/rooms/SendMessageComposer.js b/src/components/views/rooms/SendMessageComposer.js index f6e5830329..d98a1a55cb 100644 --- a/src/components/views/rooms/SendMessageComposer.js +++ b/src/components/views/rooms/SendMessageComposer.js @@ -104,6 +104,9 @@ export default class SendMessageComposer extends React.Component { }; _onKeyDown = (event) => { + if (this._editorRef.shouldIgnoreKeyDownEvents()) { + return; + } const hasModifier = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey; if (event.key === "Enter" && !hasModifier) { this._sendMessage();