diff --git a/packages/lexical/src/LexicalUpdates.ts b/packages/lexical/src/LexicalUpdates.ts index 7ad461ff552..b33612afab3 100644 --- a/packages/lexical/src/LexicalUpdates.ts +++ b/packages/lexical/src/LexicalUpdates.ts @@ -21,7 +21,7 @@ import type {LexicalNode, SerializedLexicalNode} from './LexicalNode'; import invariant from 'shared/invariant'; -import {$isElementNode, $isTextNode} from '.'; +import {$isElementNode, $isTextNode, SELECTION_CHANGE_COMMAND} from '.'; import {FULL_RECONCILE, NO_DIRTY_NODES} from './LexicalConstants'; import {resetEditor} from './LexicalEditor'; import { @@ -596,7 +596,13 @@ export function commitPendingUpdates(editor: LexicalEditor): void { dirtyLeaves, ); } - + if ( + !$isRangeSelection(pendingSelection) && + pendingSelection !== null && + (currentSelection === null || !currentSelection.is(pendingSelection)) + ) { + editor.dispatchCommand(SELECTION_CHANGE_COMMAND, undefined); + } /** * Capture pendingDecorators after garbage collecting detached decorators */