From aa21e4a4089576c91d6d9dabcc2969881d04801a Mon Sep 17 00:00:00 2001 From: Andrei Draganescu Date: Tue, 6 Dec 2022 13:24:07 +0000 Subject: [PATCH] fix loading of page list options loading --- packages/block-library/src/page-list/edit.js | 42 ++++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/block-library/src/page-list/edit.js b/packages/block-library/src/page-list/edit.js index 19c899cc64559..3be276ead3598 100644 --- a/packages/block-library/src/page-list/edit.js +++ b/packages/block-library/src/page-list/edit.js @@ -158,15 +158,13 @@ export default function PageListEdit( { } }; - const useParentOptions = () => { - return pages?.reduce( ( accumulator, page ) => { - accumulator.push( { - value: page.id, - label: page.title.rendered, - } ); - return accumulator; - }, [] ); - }; + const parentOptions = pages?.reduce( ( accumulator, page ) => { + accumulator.push( { + value: page.id, + label: page.title.rendered, + } ); + return accumulator; + }, [] ); useEffect( () => { __unstableMarkNextChangeAsNotPersistent(); @@ -179,18 +177,20 @@ export default function PageListEdit( { <> - - setAttributes( { parentPageID: value ?? 0 } ) - } - help={ __( - 'Choose a page to show only its subpages.' - ) } - /> + { parentOptions && ( + + setAttributes( { parentPageID: value ?? 0 } ) + } + help={ __( + 'Choose a page to show only its subpages.' + ) } + /> + ) } { allowConvertToLinks && (