diff --git a/src/editor/contents.js b/src/editor/contents.js index 9cc2b04e..19fd1eae 100644 --- a/src/editor/contents.js +++ b/src/editor/contents.js @@ -278,8 +278,11 @@ export default class Contents { let focusNode = null this.editor.update(() => { - if ($isNodeSelection(this.#selection.current)) { - const nodesToRemove = this.#selection.current.getNodes() + // Use fresh selection - cached this.#selection.current may be frozen + // See: https://github.com/facebook/lexical/issues/6290 + const selection = $getSelection() + if ($isNodeSelection(selection)) { + const nodesToRemove = selection.getNodes() if (nodesToRemove.length === 0) return focusNode = this.#findAdjacentNodeTo(nodesToRemove) diff --git a/src/editor/selection.js b/src/editor/selection.js index 4b3ebb7d..bdd4d19f 100644 --- a/src/editor/selection.js +++ b/src/editor/selection.js @@ -409,7 +409,12 @@ export default class Selection { if (this.current) { this.editor.update(() => { this.clear() - fn(this.current.getNodes()[0]) + // Use fresh selection - cached this.current may be frozen + // See: https://github.com/facebook/lexical/issues/6290 + const selection = $getSelection() + if ($isNodeSelection(selection)) { + fn(selection.getNodes()[0]) + } this.editor.focus() }) }