Skip to content

Commit

Permalink
fix: Disables GenericMenu without any sections or items (#30319)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjy7 authored Sep 19, 2023
1 parent 5f165f0 commit 696bbc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-papayas-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

fix: Disables GenericMenu without any sections or items
9 changes: 7 additions & 2 deletions apps/meteor/client/components/GenericMenu/GenericMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { IconButton } from '@rocket.chat/fuselage';
import { MenuItem, MenuSection, MenuV2 } from '@rocket.chat/fuselage';
import { IconButton, MenuItem, MenuSection, MenuV2 } from '@rocket.chat/fuselage';
import { useTranslation } from '@rocket.chat/ui-contexts';
import type { ComponentProps, ReactNode } from 'react';
import React from 'react';
Expand Down Expand Up @@ -43,6 +42,12 @@ const GenericMenu = ({ title, icon = 'menu', onAction, ...props }: GenericMenuPr
const handleItems = (items: GenericMenuItemProps[]) =>
hasIcon ? items.map((item) => ({ ...item, gap: !item.icon && !item.status })) : items;

const isMenuEmpty = !(sections && sections.length > 0) && !(items && items.length > 0);

if (isMenuEmpty) {
return <IconButton icon={icon} disabled />;
}

return (
<>
{sections && (
Expand Down

0 comments on commit 696bbc4

Please sign in to comment.