Skip to content

Commit

Permalink
Force the selection when composition is resolved (facebookarchive#2094)
Browse files Browse the repository at this point in the history
Summary:
Fixes facebookarchive#2093.
Pull Request resolved: facebookarchive#2094

Reviewed By: claudiopro

Differential Revision: D21770987

Pulled By: mrkev

fbshipit-source-id: f198a89ce2eae69328daa5ce917085ce0d726dba
  • Loading branch information
robbertbrak authored and vilemj-Viclick committed Jul 16, 2020
1 parent fec3c38 commit 466478d
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ 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');
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`.
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 466478d

Please sign in to comment.