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

Commit

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

Reviewed By: claudiopro

Differential Revision: D21770987

Pulled By: mrkev

fbshipit-source-id: f198a89ce2eae69328daa5ce917085ce0d726dba
  • Loading branch information
robbertbrak authored and facebook-github-bot committed Jul 2, 2020
1 parent a08a8fa commit 3be4d37
Showing 1 changed file with 11 additions and 4 deletions.
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 3be4d37

Please sign in to comment.