From 612d6c55f6ac5ca5c97de7f375a3d3ab7aab8ea3 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 8 May 2024 18:49:08 +0400 Subject: [PATCH] Edit Post: Fix the 'usePaddingAppender' error --- .../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 );