From 8d488cc7167d8539d313ad18fc167347bd209c18 Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Thu, 4 Jul 2024 12:32:00 +0200 Subject: [PATCH] Fix: Crash when onActionPerformed is used with callback actions. (#63120) Co-authored-by: jorgefilipecosta --- .../src/components/post-actions/actions.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/editor/src/components/post-actions/actions.js b/packages/editor/src/components/post-actions/actions.js index cd1036faacdfd2..2f97d0aa9d0a8e 100644 --- a/packages/editor/src/components/post-actions/actions.js +++ b/packages/editor/src/components/post-actions/actions.js @@ -955,12 +955,18 @@ export function usePostActions( { postType, onActionPerformed, context } ) { const existingCallback = actions[ i ].callback; actions[ i ] = { ...actions[ i ], - callback: ( items, { _onActionPerformed } ) => { - existingCallback( items, ( _items ) => { - if ( _onActionPerformed ) { - _onActionPerformed( _items ); - } - onActionPerformed( actions[ i ].id, _items ); + callback: ( items, argsObject ) => { + existingCallback( items, { + ...argsObject, + onActionPerformed: ( _items ) => { + if ( argsObject.onActionPerformed ) { + argsObject.onActionPerformed( _items ); + } + onActionPerformed( + actions[ i ].id, + _items + ); + }, } ); }, };