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

Fix scroll behavior when node has tab chars #2256

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions src/component/handlers/edit/editOnBeforeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,6 @@ function editOnBeforeInput(
editor._latestCommittedEditorState,
);
}
if (!mustPreventNative) {
// Chrome will also split up a node into two pieces if it contains a Tab
// char, for no explicable reason. Seemingly caused by this commit:
// https://chromium.googlesource.com/chromium/src/+/013ac5eaf3%5E%21/

// in test environment, e.target is not available
const nativeSelection = (e.currentTarget
? e.currentTarget.ownerDocument.defaultView
: global
).getSelection();
// Selection is necessarily collapsed at this point due to earlier check.
if (
nativeSelection.anchorNode &&
nativeSelection.anchorNode.nodeType === Node.TEXT_NODE
) {
// See isTabHTMLSpanElement in chromium EditingUtilities.cpp.
const parentNode = nativeSelection.anchorNode.parentNode;
mustPreventNative =
parentNode.nodeName === 'SPAN' &&
parentNode.firstChild.nodeType === Node.TEXT_NODE &&
parentNode.firstChild.nodeValue.indexOf('\t') !== -1;
}
}
if (!mustPreventNative) {
// Let's say we have a decorator that highlights hashtags. In many cases
// we need to prevent native behavior and rerender ourselves --
Expand Down