From cdc6f6b6da2697a77c37a012ccd9a5ff4aca4cca Mon Sep 17 00:00:00 2001 From: Dave Smith Date: Fri, 18 Oct 2024 10:27:15 +0100 Subject: [PATCH] Set correct destination index --- .../src/components/inserter/hooks/use-insertion-point.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js b/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js index fa9110cfa10d7e..345493cbcf3c95 100644 --- a/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js +++ b/packages/block-editor/src/components/inserter/hooks/use-insertion-point.js @@ -97,13 +97,16 @@ function useInsertionPoint( { if ( sectionRootClientId === selectedBlockClientId ) { _destinationRootClientId = sectionRootClientId; + _destinationIndex = getBlockOrder( + _destinationRootClientId + ).length; } else { _destinationRootClientId = getBlockRootClientId( selectedBlockClientId ); + _destinationIndex = + getBlockIndex( selectedBlockClientId ) + 1; } - - _destinationIndex = getBlockIndex( selectedBlockClientId ) + 1; } else { // Insert at the end of the list. _destinationIndex = getBlockOrder(