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

Commit 1a5b27a

Browse files
sophiebitsfacebook-github-bot
authored andcommitted
Remove gating on draft_non_native_insertion_forces_selection
Summary: No bugs reported. Reviewed By: stopachka Differential Revision: D9273799 fbshipit-source-id: ee714cbf0d76baca6f121939082138b53118f106
1 parent 05208a8 commit 1a5b27a

File tree

3 files changed

+17
-52
lines changed

3 files changed

+17
-52
lines changed

src/component/handlers/edit/__tests__/__snapshots__/editOnBeforeInput.test.js.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Immutable.Record {
8181
"focusKey": "a",
8282
"focusOffset": 1,
8383
"isBackward": false,
84-
"hasFocus": true,
84+
"hasFocus": false,
8585
}
8686
`;
8787

@@ -91,7 +91,7 @@ Immutable.Record {
9191
"anchorOffset": 1,
9292
"focusKey": "a",
9393
"focusOffset": 1,
94-
"isBackward": true,
95-
"hasFocus": true,
94+
"isBackward": false,
95+
"hasFocus": false,
9696
}
9797
`;

src/component/handlers/edit/editOnBeforeInput.js

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const EditorState = require('EditorState');
2020
const UserAgent = require('UserAgent');
2121

2222
const getEntityKeyForSelection = require('getEntityKeyForSelection');
23-
const gkx = require('gkx');
2423
const isEventHandled = require('isEventHandled');
2524
const isSelectionAtLeafStart = require('isSelectionAtLeafStart');
2625
const nullthrows = require('nullthrows');
@@ -37,10 +36,6 @@ const FF_QUICKFIND_CHAR = "'";
3736
const FF_QUICKFIND_LINK_CHAR = '/';
3837
const isFirefox = UserAgent.isBrowser('Firefox');
3938

40-
const nonNativeInsertionForcesSelection = gkx(
41-
'draft_non_native_insertion_forces_selection',
42-
);
43-
4439
function mustPreventDefaultForCharacter(character: string): boolean {
4540
return (
4641
isFirefox &&
@@ -122,46 +117,22 @@ function editOnBeforeInput(
122117
// is not collapsed, we will re-render.
123118
const selection = editorState.getSelection();
124119
const selectionStart = selection.getStartOffset();
125-
const selectionEnd = selection.getEndOffset();
126120
const anchorKey = selection.getAnchorKey();
127121

128122
if (!selection.isCollapsed()) {
129123
e.preventDefault();
130-
131-
// If the currently selected text matches what the user is trying to
132-
// replace it with, let's just update the `SelectionState`. If not, update
133-
// the `ContentState` with the new text.
134-
const currentlySelectedChars = editorState
135-
.getCurrentContent()
136-
.getPlainText()
137-
.slice(selectionStart, selectionEnd);
138-
if (
139-
!nonNativeInsertionForcesSelection &&
140-
chars === currentlySelectedChars
141-
) {
142-
editor.update(
143-
EditorState.forceSelection(
144-
editorState,
145-
selection.merge({
146-
anchorOffset: selectionEnd,
147-
focusOffset: selectionEnd,
148-
}),
149-
),
150-
);
151-
} else {
152-
editor.update(
153-
replaceText(
154-
editorState,
155-
chars,
156-
editorState.getCurrentInlineStyle(),
157-
getEntityKeyForSelection(
158-
editorState.getCurrentContent(),
159-
editorState.getSelection(),
160-
),
161-
true,
124+
editor.update(
125+
replaceText(
126+
editorState,
127+
chars,
128+
editorState.getCurrentInlineStyle(),
129+
getEntityKeyForSelection(
130+
editorState.getCurrentContent(),
131+
editorState.getSelection(),
162132
),
163-
);
164-
}
133+
true,
134+
),
135+
);
165136
return;
166137
}
167138

@@ -270,11 +241,9 @@ function editOnBeforeInput(
270241

271242
if (mustPreventNative) {
272243
e.preventDefault();
273-
if (nonNativeInsertionForcesSelection) {
274-
newEditorState = EditorState.set(newEditorState, {
275-
forceSelection: true,
276-
});
277-
}
244+
newEditorState = EditorState.set(newEditorState, {
245+
forceSelection: true,
246+
});
278247
editor.update(newEditorState);
279248
return;
280249
}

src/model/immutable/EditorState.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const ContentState = require('ContentState');
2424
const EditorBidiService = require('EditorBidiService');
2525
const SelectionState = require('SelectionState');
2626

27-
const gkx = require('gkx');
2827
const Immutable = require('immutable');
2928

3029
const {OrderedSet, Record, Stack} = Immutable;
@@ -348,9 +347,6 @@ class EditorState {
348347
return editorState;
349348
}
350349

351-
if (!gkx('draft_non_native_insertion_forces_selection')) {
352-
forceSelection = changeType !== 'insert-characters';
353-
}
354350
const directionMap = EditorBidiService.getDirectionMap(
355351
contentState,
356352
editorState.getDirectionMap(),

0 commit comments

Comments
 (0)