From f2503b1eed3cc07b1fb9be92519d7ae81e07890a Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Thu, 9 May 2024 13:20:27 +0400 Subject: [PATCH] Edit Post: Fix the 'usePaddingAppender' error (#61500) Co-authored-by: Mamaduka Co-authored-by: ellatrix --- .../src/components/visual-editor/use-padding-appender.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/edit-post/src/components/visual-editor/use-padding-appender.js b/packages/edit-post/src/components/visual-editor/use-padding-appender.js index c091443495740..ff342ded90817 100644 --- a/packages/edit-post/src/components/visual-editor/use-padding-appender.js +++ b/packages/edit-post/src/components/visual-editor/use-padding-appender.js @@ -27,7 +27,7 @@ export function usePaddingAppender() { return; } - // only handle clicks under the last child + // Only handle clicks under the last child. const lastChild = node.lastElementChild; if ( ! lastChild ) { return; @@ -44,6 +44,12 @@ export function usePaddingAppender() { .select( blockEditorStore ) .getBlockOrder( '' ); const lastBlockClientId = blockOrder[ blockOrder.length - 1 ]; + + // Do nothing when only default block appender is present. + if ( ! lastBlockClientId ) { + return; + } + const lastBlock = registry .select( blockEditorStore ) .getBlock( lastBlockClientId );