From 2cc8058630b74eff7ea8554d15d00dabf9520e12 Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Fri, 6 Dec 2024 15:59:55 +0000 Subject: [PATCH] Ensure Move to trash is always at end of list --- packages/editor/src/components/post-actions/actions.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/editor/src/components/post-actions/actions.js b/packages/editor/src/components/post-actions/actions.js index d8da5cb51cf1d8..e26bbd28222b62 100644 --- a/packages/editor/src/components/post-actions/actions.js +++ b/packages/editor/src/components/post-actions/actions.js @@ -68,6 +68,14 @@ export function usePostActions( { postType, onActionPerformed, context } ) { ); } + // Ensure "Move to trash" is always the last action. + actions = actions.sort( ( a, b ) => { + if ( b.id === 'move-to-trash' ) { + return -1; + } + return 0; + } ); + // 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.