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 authored Jul 13, 2023
1 parent c7391e1 commit 2001df4
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,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

1 comment on commit 2001df4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 2001df4.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5544476083
📝 Reported issues:

Please sign in to comment.