Skip to content

Commit 2001df4

Browse files
authored
Avoid passing undefined selectedBlockClientId in BlockActionsMenu (#52595)
When determining if the block is groupable/ungroupable, we now avoid passing an undefined value which leads to a crash.
1 parent c7391e1 commit 2001df4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/block-editor/src/components/block-toolbar/block-toolbar-menu.native.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ const BlockActionsMenu = ( {
100100
} = getMoversSetup( isStackedHorizontally, moversOptions );
101101

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

0 commit comments

Comments
 (0)