Skip to content

Commit cd345db

Browse files
committed
fix: also handle empty arrays
1 parent 77747b8 commit cd345db

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

packages/compass-components/src/components/context-menu.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,10 @@ export function useContextMenuGroups(
142142
// Cleanup all undefined fields across items and groups which is used
143143
// for conditional displaying of groups and items.
144144
return groups
145-
.filter((groupItems) => groupItems !== undefined)
146-
.map((groupItems) =>
147-
groupItems.filter(
148-
(item): item is ContextMenuItem => item !== undefined
149-
)
150-
);
145+
.filter(
146+
(groupItems) => groupItems !== undefined && groupItems.length > 0
147+
)
148+
.map((groupItems) => groupItems!.filter((item) => item !== undefined));
151149
},
152150
// eslint-disable-next-line react-hooks/exhaustive-deps
153151
dependencies

0 commit comments

Comments
 (0)