diff --git a/src/component/handlers/composition/DraftEditorCompositionHandler.js b/src/component/handlers/composition/DraftEditorCompositionHandler.js index 8b459d347c..e5f6d1d721 100644 --- a/src/component/handlers/composition/DraftEditorCompositionHandler.js +++ b/src/component/handlers/composition/DraftEditorCompositionHandler.js @@ -18,6 +18,7 @@ const DraftModifier = require('DraftModifier'); const DraftOffsetKey = require('DraftOffsetKey'); const EditorState = require('EditorState'); const Keys = require('Keys'); +const UserAgent = require('UserAgent'); const editOnSelect = require('editOnSelect'); const getContentEditableContainer = require('getContentEditableContainer'); @@ -25,6 +26,8 @@ const getDraftEditorSelection = require('getDraftEditorSelection'); const getEntityKeyForSelection = require('getEntityKeyForSelection'); const nullthrows = require('nullthrows'); +const isIE = UserAgent.isBrowser('IE'); + /** * Millisecond delay to allow `compositionstart` to fire again upon * `compositionend`. @@ -225,10 +228,14 @@ const DraftEditorCompositionHandler = { editor.restoreEditorDOM(); - const editorStateWithUpdatedSelection = EditorState.acceptSelection( - editorState, - compositionEndSelectionState, - ); + // See: + // - https://github.com/facebook/draft-js/issues/2093 + // - https://github.com/facebook/draft-js/pull/2094 + // Apply this fix only in IE for now. We can test it in + // other browsers in the future to ensure no regressions + const editorStateWithUpdatedSelection = isIE + ? EditorState.forceSelection(editorState, compositionEndSelectionState) + : EditorState.acceptSelection(editorState, compositionEndSelectionState); editor.update( EditorState.push(