diff --git a/packages/lexical-table/src/LexicalTableObserver.ts b/packages/lexical-table/src/LexicalTableObserver.ts index 2f76ce0712a..3dc2a77b1e6 100644 --- a/packages/lexical-table/src/LexicalTableObserver.ts +++ b/packages/lexical-table/src/LexicalTableObserver.ts @@ -18,7 +18,6 @@ import { $createTextNode, $getEditor, $getNodeByKey, - $getRoot, $getSelection, $isElementNode, $isParagraphNode, @@ -470,8 +469,6 @@ export class TableObserver { tableNode.selectPrevious(); // Delete entire table tableNode.remove(); - const rootNode = $getRoot(); - rootNode.selectStart(); return; } diff --git a/packages/lexical-table/src/LexicalTableSelectionHelpers.ts b/packages/lexical-table/src/LexicalTableSelectionHelpers.ts index 5d010cc0bc2..970ddd17132 100644 --- a/packages/lexical-table/src/LexicalTableSelectionHelpers.ts +++ b/packages/lexical-table/src/LexicalTableSelectionHelpers.ts @@ -456,6 +456,10 @@ export function applyTableHandlers( return false; } + if (!$isSelectionInTable(selection, tableNode)) { + return false; + } + if ($isTableSelection(selection)) { if (event) { event.preventDefault();