Skip to content

Commit

Permalink
Fix: Crash when onActionPerformed is used with callback actions. (#63120
Browse files Browse the repository at this point in the history
)

Co-authored-by: jorgefilipecosta <[email protected]>
  • Loading branch information
jorgefilipecosta and jorgefilipecosta authored Jul 4, 2024
1 parent cae3225 commit 78fc70e
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
},
} );
},
};
Expand Down

0 comments on commit 78fc70e

Please sign in to comment.