Skip to content

Commit 90b780a

Browse files
authored
selectionChange fix (#3623)
1 parent 5d4672c commit 90b780a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

packages/lexical/src/LexicalUpdates.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import type {LexicalNode, SerializedLexicalNode} from './LexicalNode';
2121

2222
import invariant from 'shared/invariant';
2323

24-
import {$isElementNode, $isTextNode} from '.';
24+
import {$isElementNode, $isTextNode, SELECTION_CHANGE_COMMAND} from '.';
2525
import {FULL_RECONCILE, NO_DIRTY_NODES} from './LexicalConstants';
2626
import {resetEditor} from './LexicalEditor';
2727
import {
@@ -596,7 +596,13 @@ export function commitPendingUpdates(editor: LexicalEditor): void {
596596
dirtyLeaves,
597597
);
598598
}
599-
599+
if (
600+
!$isRangeSelection(pendingSelection) &&
601+
pendingSelection !== null &&
602+
(currentSelection === null || !currentSelection.is(pendingSelection))
603+
) {
604+
editor.dispatchCommand(SELECTION_CHANGE_COMMAND, undefined);
605+
}
600606
/**
601607
* Capture pendingDecorators after garbage collecting detached decorators
602608
*/

0 commit comments

Comments
 (0)