From 4d151722fff14f43792fbbe8d7f7ef5a5d5398b8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 24 Sep 2019 15:32:08 +0200 Subject: [PATCH] delay DOM modification after compositionend --- src/components/views/rooms/BasicMessageComposer.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/BasicMessageComposer.js b/src/components/views/rooms/BasicMessageComposer.js index 110df355fe..14c850b9a3 100644 --- a/src/components/views/rooms/BasicMessageComposer.js +++ b/src/components/views/rooms/BasicMessageComposer.js @@ -170,8 +170,13 @@ export default class BasicMessageEditor extends React.Component { _onCompositionEnd = (event) => { this._isIMEComposing = false; // some browsers (chromium) don't fire an input event after ending a composition - // so trigger a model update after the composition is done by calling the input handler - this._onInput({inputType: "insertCompositionText"}); + // so trigger a model update after the composition is done by calling the input handler. + // do this async though, as modifying the DOM from the compositionend event might confuse the composition. + setTimeout(() => { + this._onInput({inputType: "insertCompositionText"}); + }, 0); + } + } _onPaste = (event) => {