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

Commit

Permalink
Fix scroll behavior when node has tab chars (#2256)
Browse files Browse the repository at this point in the history
Summary:
Closes #2254

Problem behavior and reasoning behind solution is described in the issue.

The linter issues are unrelated to the file I changed so I left them alone in order to keep this commit atomic.
Pull Request resolved: #2256

Reviewed By: claudiopro

Differential Revision: D18734244

Pulled By: mrkev

fbshipit-source-id: eb5a1a91f7c3f27fced1e37f5822bc3e126fb332
  • Loading branch information
qualitymanifest authored and facebook-github-bot committed Dec 13, 2019
1 parent 3b6d231 commit 5d37c03
Showing 1 changed file with 0 additions and 23 deletions.
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

0 comments on commit 5d37c03

Please sign in to comment.