diff --git a/src/component/handlers/edit/__tests__/__snapshots__/editOnBeforeInput.test.js.snap b/src/component/handlers/edit/__tests__/__snapshots__/editOnBeforeInput.test.js.snap index fa89390364..52693c2c15 100644 --- a/src/component/handlers/edit/__tests__/__snapshots__/editOnBeforeInput.test.js.snap +++ b/src/component/handlers/edit/__tests__/__snapshots__/editOnBeforeInput.test.js.snap @@ -81,7 +81,7 @@ Immutable.Record { "focusKey": "a", "focusOffset": 1, "isBackward": false, - "hasFocus": true, + "hasFocus": false, } `; @@ -91,7 +91,7 @@ Immutable.Record { "anchorOffset": 1, "focusKey": "a", "focusOffset": 1, - "isBackward": true, - "hasFocus": true, + "isBackward": false, + "hasFocus": false, } `; diff --git a/src/component/handlers/edit/editOnBeforeInput.js b/src/component/handlers/edit/editOnBeforeInput.js index 6a51506e21..b77cffe859 100644 --- a/src/component/handlers/edit/editOnBeforeInput.js +++ b/src/component/handlers/edit/editOnBeforeInput.js @@ -20,7 +20,6 @@ const EditorState = require('EditorState'); const UserAgent = require('UserAgent'); const getEntityKeyForSelection = require('getEntityKeyForSelection'); -const gkx = require('gkx'); const isEventHandled = require('isEventHandled'); const isSelectionAtLeafStart = require('isSelectionAtLeafStart'); const nullthrows = require('nullthrows'); @@ -37,10 +36,6 @@ const FF_QUICKFIND_CHAR = "'"; const FF_QUICKFIND_LINK_CHAR = '/'; const isFirefox = UserAgent.isBrowser('Firefox'); -const nonNativeInsertionForcesSelection = gkx( - 'draft_non_native_insertion_forces_selection', -); - function mustPreventDefaultForCharacter(character: string): boolean { return ( isFirefox && @@ -122,46 +117,22 @@ function editOnBeforeInput( // is not collapsed, we will re-render. const selection = editorState.getSelection(); const selectionStart = selection.getStartOffset(); - const selectionEnd = selection.getEndOffset(); const anchorKey = selection.getAnchorKey(); if (!selection.isCollapsed()) { e.preventDefault(); - - // If the currently selected text matches what the user is trying to - // replace it with, let's just update the `SelectionState`. If not, update - // the `ContentState` with the new text. - const currentlySelectedChars = editorState - .getCurrentContent() - .getPlainText() - .slice(selectionStart, selectionEnd); - if ( - !nonNativeInsertionForcesSelection && - chars === currentlySelectedChars - ) { - editor.update( - EditorState.forceSelection( - editorState, - selection.merge({ - anchorOffset: selectionEnd, - focusOffset: selectionEnd, - }), - ), - ); - } else { - editor.update( - replaceText( - editorState, - chars, - editorState.getCurrentInlineStyle(), - getEntityKeyForSelection( - editorState.getCurrentContent(), - editorState.getSelection(), - ), - true, + editor.update( + replaceText( + editorState, + chars, + editorState.getCurrentInlineStyle(), + getEntityKeyForSelection( + editorState.getCurrentContent(), + editorState.getSelection(), ), - ); - } + true, + ), + ); return; } @@ -270,11 +241,9 @@ function editOnBeforeInput( if (mustPreventNative) { e.preventDefault(); - if (nonNativeInsertionForcesSelection) { - newEditorState = EditorState.set(newEditorState, { - forceSelection: true, - }); - } + newEditorState = EditorState.set(newEditorState, { + forceSelection: true, + }); editor.update(newEditorState); return; } diff --git a/src/model/immutable/EditorState.js b/src/model/immutable/EditorState.js index 5b52d9e64a..a7ca1be53c 100644 --- a/src/model/immutable/EditorState.js +++ b/src/model/immutable/EditorState.js @@ -24,7 +24,6 @@ const ContentState = require('ContentState'); const EditorBidiService = require('EditorBidiService'); const SelectionState = require('SelectionState'); -const gkx = require('gkx'); const Immutable = require('immutable'); const {OrderedSet, Record, Stack} = Immutable; @@ -348,9 +347,6 @@ class EditorState { return editorState; } - if (!gkx('draft_non_native_insertion_forces_selection')) { - forceSelection = changeType !== 'insert-characters'; - } const directionMap = EditorBidiService.getDirectionMap( contentState, editorState.getDirectionMap(),