diff --git a/packages/lexical/src/LexicalReconciler.ts b/packages/lexical/src/LexicalReconciler.ts index 1252ebb0b5b..5359298a408 100644 --- a/packages/lexical/src/LexicalReconciler.ts +++ b/packages/lexical/src/LexicalReconciler.ts @@ -502,8 +502,8 @@ function reconcileChildren( nextElement, prevChildren, nextChildren, - prevChildren.length, - nextChildren.length, + prevChildrenSize, + nextChildrenSize, dom, ); } diff --git a/packages/lexical/src/LexicalSelection.ts b/packages/lexical/src/LexicalSelection.ts index b2628271b88..520541f8e9b 100644 --- a/packages/lexical/src/LexicalSelection.ts +++ b/packages/lexical/src/LexicalSelection.ts @@ -1926,6 +1926,10 @@ function internalResolveSelectionPoint( return null; } if ($isElementNode(resolvedElement)) { + resolvedOffset = Math.min( + resolvedElement.getChildrenSize(), + resolvedOffset, + ); let child = resolvedElement.getChildAtIndex(resolvedOffset); if ( $isElementNode(child) &&