ignore keydown events while doing IME composition

This commit is contained in:
Bruno Windels 2019-09-24 15:32:30 +02:00
parent 4d151722ff
commit 9f47fad305
3 changed files with 8 additions and 0 deletions

View file

@ -177,6 +177,8 @@ export default class BasicMessageEditor extends React.Component {
}, 0); }, 0);
} }
shouldIgnoreKeyDownEvents() {
return this._isIMEComposing;
} }
_onPaste = (event) => { _onPaste = (event) => {

View file

@ -127,6 +127,9 @@ export default class EditMessageComposer extends React.Component {
} }
_onKeyDown = (event) => { _onKeyDown = (event) => {
if (this._editorRef.shouldIgnoreKeyDownEvents()) {
return;
}
if (event.metaKey || event.altKey || event.shiftKey) { if (event.metaKey || event.altKey || event.shiftKey) {
return; return;
} }

View file

@ -104,6 +104,9 @@ export default class SendMessageComposer extends React.Component {
}; };
_onKeyDown = (event) => { _onKeyDown = (event) => {
if (this._editorRef.shouldIgnoreKeyDownEvents()) {
return;
}
const hasModifier = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey; const hasModifier = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
if (event.key === "Enter" && !hasModifier) { if (event.key === "Enter" && !hasModifier) {
this._sendMessage(); this._sendMessage();