From 69161e79bf53a785e8fccb622cfaeca8f2ae830d Mon Sep 17 00:00:00 2001 From: Serey Roth <88986106+serey-roth@users.noreply.github.com> Date: Tue, 21 May 2024 14:56:55 -0700 Subject: [PATCH] Bug Fix: Insert paragraph at table's edge inside a collapsible (#6159) --- .../src/LexicalTableSelectionHelpers.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/lexical-table/src/LexicalTableSelectionHelpers.ts b/packages/lexical-table/src/LexicalTableSelectionHelpers.ts index 7d89e3fb961..3c4d7fa0303 100644 --- a/packages/lexical-table/src/LexicalTableSelectionHelpers.ts +++ b/packages/lexical-table/src/LexicalTableSelectionHelpers.ts @@ -1655,9 +1655,19 @@ function $getTableEdgeCursorPosition( selection: RangeSelection, tableNode: TableNode, ) { + const tableNodeParent = tableNode.getParent(); + if (!tableNodeParent) { + return undefined; + } + + const tableNodeParentDOM = editor.getElementByKey(tableNodeParent.getKey()); + if (!tableNodeParentDOM) { + return undefined; + } + // TODO: Add support for nested tables const domSelection = window.getSelection(); - if (!domSelection || domSelection.anchorNode !== editor.getRootElement()) { + if (!domSelection || domSelection.anchorNode !== tableNodeParentDOM) { return undefined; }