Skip to content

Commit

Permalink
Avoid passing undefined selectedBlockClientId in BlockActionsMenu (
Browse files Browse the repository at this point in the history
…#52595)

When determining if the block is groupable/ungroupable, we now avoid passing an undefined value which leads to a crash.
  • Loading branch information
fluiddot committed Jul 13, 2023
1 parent 0fcd596 commit f17d703
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ const BlockActionsMenu = ( {
} = getMoversSetup( isStackedHorizontally, moversOptions );

// Check if selected block is Groupable and/or Ungroupable.
const convertToGroupButtonProps = useConvertToGroupButtonProps( [
selectedBlockClientId,
] );
const convertToGroupButtonProps = useConvertToGroupButtonProps(
// `selectedBlockClientId` can be undefined in some cases where this
// component gets re-rendered right after the block is removed.
selectedBlockClientId ? [ selectedBlockClientId ] : []
);
const { isGroupable, isUngroupable } = convertToGroupButtonProps;
const showConvertToGroupButton =
( isGroupable || isUngroupable ) && canRemove;
Expand Down

0 comments on commit f17d703

Please sign in to comment.