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

Commit

Permalink
Only extend selection if it has ranges in setDraftEditorSelection.js
Browse files Browse the repository at this point in the history
Summary: Needed for writing assistance. More correct than D20659377 IMO.

Reviewed By: raedle

Differential Revision: D20713362

fbshipit-source-id: 77b118ceb50eb50b385e0385c2cd07169512ddc4
  • Loading branch information
mrkev authored and facebook-github-bot committed Mar 30, 2020
1 parent 538d864 commit d53fa7a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/component/selection/setDraftEditorSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,11 @@ function addFocusToSelection(
// logging to catch bug that is being reported in t18110632
const nodeWasFocus = node === selection.focusNode;
try {
selection.extend(node, offset);
// Fixes some reports of "InvalidStateError: Failed to execute 'extend' on
// 'Selection': This Selection object doesn't have any Ranges."
if (selection.rangeCount > 0) {
selection.extend(node, offset);
}
} catch (e) {
DraftJsDebugLogging.logSelectionStateFailure({
anonymizedDom: getAnonymizedEditorDOM(node, function(n) {
Expand Down

0 comments on commit d53fa7a

Please sign in to comment.