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

Commit

Permalink
Short-circuit getUpdatedSelectionState for invalid selection updates …
Browse files Browse the repository at this point in the history
…on prod

Summary:
The code already did this for __DEV__, but it was misswritten, since instead of skipping the wanring on prod, it skipped the whole check.

This essentially deals with empty-string keys, which mean nothing.

This wasn't much of an issue— we'd simply not get any leafs and exit on a following check.

Reviewed By: claudiopro

Differential Revision: D21145150

fbshipit-source-id: bb78aa076d98f5d642a2ae8eb13c158dde8a76e3
  • Loading branch information
mrkev authored and facebook-github-bot committed Apr 22, 2020
1 parent 31dec71 commit 0585b68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/component/selection/getUpdatedSelectionState.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ function getUpdatedSelectionState(
focusOffset: number,
): SelectionState {
const selection: SelectionState = nullthrows(editorState.getSelection());
if (__DEV__) {
if (!anchorKey || !focusKey) {
if (!anchorKey || !focusKey) {
// If we cannot make sense of the updated selection state, stick to the current one.
if (__DEV__) {
/* eslint-disable-next-line */
console.warn('Invalid selection state.', arguments, editorState.toJS());
return selection;
}
return selection;
}

const anchorPath = DraftOffsetKey.decode(anchorKey);
Expand Down

0 comments on commit 0585b68

Please sign in to comment.