Skip to content

Commit

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

Co-authored-by: jorgefilipecosta <[email protected]>
  • Loading branch information
2 people authored and carstingaxion committed Jul 18, 2024
1 parent 555edbc commit 8d488cc
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 8d488cc

Please sign in to comment.