[Bug Fix] Clone a node and use $setSelection instead of assigning dirty to true directly. (#7401)

This commit is contained in:
Yuncheng Lu
2025-03-30 08:22:46 +08:00
committed by GitHub
parent 4d459e3f47
commit 5a4e10c0dd

View File

@ -34,6 +34,7 @@ import {
import {
$addUpdateTag,
$onUpdate,
$setSelection,
createUID,
dispatchCommand,
getCachedClassNameArray,
@ -1307,7 +1308,9 @@ export class LexicalEditor {
if (selection !== null) {
// Marking the selection dirty will force the selection back to it
selection.dirty = true;
if (!selection.dirty) {
$setSelection(selection.clone());
}
} else if (root.getChildrenSize() !== 0) {
if (options.defaultSelection === 'rootStart') {
root.selectStart();