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

Commit e7ce06b

Browse files
nmnfacebook-github-bot
authored andcommitted
Revert D20016281: Fix iOS double-space quick-type bug
Differential Revision: D20016281 Original commit changeset: aeefd5c3f17c fbshipit-source-id: b39208ab5c59a462b59d05d0db4c9bab9ffe42a7
1 parent b4e2a2d commit e7ce06b

File tree

1 file changed

+5
-38
lines changed

1 file changed

+5
-38
lines changed

src/component/handlers/composition/DraftEditorCompositionHandler.js

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ const RESOLVE_DELAY = 20;
4646
let resolved = false;
4747
let stillComposing = false;
4848
let domObserver = null;
49-
let beforeInputData = null;
50-
let compositionEndData = null;
5149

5250
function startDOMObserver(editor: DraftEditor) {
5351
if (!domObserver) {
@@ -57,14 +55,11 @@ function startDOMObserver(editor: DraftEditor) {
5755
}
5856

5957
const DraftEditorCompositionHandler = {
60-
onBeforeInput(_editor: DraftEditor, e: SyntheticInputEvent<>): void {
61-
beforeInputData = (beforeInputData || '') + e.data;
62-
},
6358
/**
6459
* A `compositionstart` event has fired while we're still in composition
6560
* mode. Continue the current composition session to prevent a re-render.
6661
*/
67-
onCompositionStart(editor: DraftEditor): void {
62+
onCompositionStart: function(editor: DraftEditor): void {
6863
stillComposing = true;
6964
startDOMObserver(editor);
7065
},
@@ -83,13 +78,9 @@ const DraftEditorCompositionHandler = {
8378
* twice could break the DOM, we only use the first event. Example: Arabic
8479
* Google Input Tools on Windows 8.1 fires `compositionend` three times.
8580
*/
86-
onCompositionEnd(editor: DraftEditor, e: SyntheticInputEvent<>): void {
81+
onCompositionEnd: function(editor: DraftEditor): void {
8782
resolved = false;
8883
stillComposing = false;
89-
90-
// Use e.data from the first compositionend event seen
91-
compositionEndData = compositionEndData ?? e?.data ?? null;
92-
9384
setTimeout(() => {
9485
if (!resolved) {
9586
DraftEditorCompositionHandler.resolveComposition(editor);
@@ -104,7 +95,7 @@ const DraftEditorCompositionHandler = {
10495
* the arrow keys are used to commit, prevent default so that the cursor
10596
* doesn't move, otherwise it will jump back noticeably on re-render.
10697
*/
107-
onKeyDown(editor: DraftEditor, e: SyntheticKeyboardEvent<>): void {
98+
onKeyDown: function(editor: DraftEditor, e: SyntheticKeyboardEvent<>): void {
10899
if (!stillComposing) {
109100
// If a keydown event is received after compositionend but before the
110101
// 20ms timer expires (ex: type option-E then backspace, or type A then
@@ -125,7 +116,7 @@ const DraftEditorCompositionHandler = {
125116
* characters that we do not want. `preventDefault` allows the composition
126117
* to be committed while preventing the extra characters.
127118
*/
128-
onKeyPress(_editor: DraftEditor, e: SyntheticKeyboardEvent<>): void {
119+
onKeyPress: function(editor: DraftEditor, e: SyntheticKeyboardEvent<>): void {
129120
if (e.which === Keys.RETURN) {
130121
e.preventDefault();
131122
}
@@ -146,7 +137,7 @@ const DraftEditorCompositionHandler = {
146137
* Resetting innerHTML will move focus to the beginning of the editor,
147138
* so we update to force it back to the correct place.
148139
*/
149-
resolveComposition(editor: DraftEditor): void {
140+
resolveComposition: function(editor: DraftEditor): void {
150141
if (stillComposing) {
151142
return;
152143
}
@@ -155,36 +146,12 @@ const DraftEditorCompositionHandler = {
155146
domObserver = null;
156147
resolved = true;
157148

158-
const composedChars = beforeInputData ?? compositionEndData;
159-
beforeInputData = null;
160-
compositionEndData = null;
161-
162149
let editorState = EditorState.set(editor._latestEditorState, {
163150
inCompositionMode: false,
164151
});
165152

166153
editor.exitCurrentMode();
167154

168-
if (composedChars != null) {
169-
const currentStyle = editorState.getCurrentInlineStyle();
170-
const entityKey = getEntityKeyForSelection(
171-
editorState.getCurrentContent(),
172-
editorState.getSelection(),
173-
);
174-
// If characters have been composed, re-rendering with the update
175-
// is sufficient to reset the editor.
176-
const contentState = DraftModifier.replaceText(
177-
editorState.getCurrentContent(),
178-
editorState.getSelection(),
179-
composedChars,
180-
currentStyle,
181-
entityKey,
182-
);
183-
editor.update(
184-
EditorState.push(editorState, contentState, 'insert-characters'),
185-
);
186-
}
187-
188155
if (!mutations.size) {
189156
editor.update(editorState);
190157
return;

0 commit comments

Comments
 (0)