Skip to content
This repository was archived by the owner on Feb 6, 2023. It is now read-only.

Commit 3be4d37

Browse files
robbertbrakfacebook-github-bot
authored andcommitted
Force the selection when composition is resolved (#2094)
Summary: Fixes #2093. Pull Request resolved: #2094 Reviewed By: claudiopro Differential Revision: D21770987 Pulled By: mrkev fbshipit-source-id: f198a89ce2eae69328daa5ce917085ce0d726dba
1 parent a08a8fa commit 3be4d37

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/component/handlers/composition/DraftEditorCompositionHandler.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@ const DraftModifier = require('DraftModifier');
1818
const DraftOffsetKey = require('DraftOffsetKey');
1919
const EditorState = require('EditorState');
2020
const Keys = require('Keys');
21+
const UserAgent = require('UserAgent');
2122

2223
const editOnSelect = require('editOnSelect');
2324
const getContentEditableContainer = require('getContentEditableContainer');
2425
const getDraftEditorSelection = require('getDraftEditorSelection');
2526
const getEntityKeyForSelection = require('getEntityKeyForSelection');
2627
const nullthrows = require('nullthrows');
2728

29+
const isIE = UserAgent.isBrowser('IE');
30+
2831
/**
2932
* Millisecond delay to allow `compositionstart` to fire again upon
3033
* `compositionend`.
@@ -225,10 +228,14 @@ const DraftEditorCompositionHandler = {
225228

226229
editor.restoreEditorDOM();
227230

228-
const editorStateWithUpdatedSelection = EditorState.acceptSelection(
229-
editorState,
230-
compositionEndSelectionState,
231-
);
231+
// See:
232+
// - https://github.com/facebook/draft-js/issues/2093
233+
// - https://github.com/facebook/draft-js/pull/2094
234+
// Apply this fix only in IE for now. We can test it in
235+
// other browsers in the future to ensure no regressions
236+
const editorStateWithUpdatedSelection = isIE
237+
? EditorState.forceSelection(editorState, compositionEndSelectionState)
238+
: EditorState.acceptSelection(editorState, compositionEndSelectionState);
232239

233240
editor.update(
234241
EditorState.push(

0 commit comments

Comments
 (0)