From 9addc70d0c97730253a5d2afbce8528140a2a431 Mon Sep 17 00:00:00 2001 From: Mayank Tripathi <70465598+Mayank-Tripathi32@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:27:07 +0530 Subject: [PATCH] Fix editor crash due to homepage action (#67500) Co-authored-by: Mayank-Tripathi32 Co-authored-by: t-hamano Co-authored-by: oandregal --- 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 1b6ff4fbe384b..808134ea969a1 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.