From c2879f6d1387d5f9bb827d0213d8cdb7f3aef5ee Mon Sep 17 00:00:00 2001 From: Mayank-Tripathi32 Date: Tue, 3 Dec 2024 01:48:34 +0530 Subject: [PATCH] fix: editor crash due to homepage action --- packages/editor/src/components/post-actions/actions.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/editor/src/components/post-actions/actions.js b/packages/editor/src/components/post-actions/actions.js index 1b6ff4fbe384b5..808134ea969a11 100644 --- a/packages/editor/src/components/post-actions/actions.js +++ b/packages/editor/src/components/post-actions/actions.js @@ -52,10 +52,11 @@ export function usePostActions( { postType, onActionPerformed, context } ) { }, [ registerPostTypeSchema, postType ] ); return useMemo( () => { - let actions = [ - ...defaultActions, - shouldShowSetAsHomepageAction ? setAsHomepageAction : [], - ]; + let actions = [ ...defaultActions ]; + if ( shouldShowSetAsHomepageAction ) { + actions.push( setAsHomepageAction ); + } + // Filter actions based on provided context. If not provided // all actions are returned. We'll have a single entry for getting the actions // and the consumer should provide the context to filter the actions, if needed.