Skip to content

Commit

Permalink
fix: Modal backdrop overlapping Select options (#32640)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris authored Jun 21, 2024
1 parent 5f95c4e commit 9c925a3
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-dolphins-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes the issue where the modal backdrop is overlapping the options of the `Select` component
5 changes: 3 additions & 2 deletions apps/meteor/client/components/GenericMenu/GenericMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type GenericMenuCommonProps = {
title: string;
icon?: ComponentProps<typeof IconButton>['icon'];
disabled?: boolean;
callbackAction?: () => void;
};
type GenericMenuConditionalProps =
| {
Expand All @@ -28,7 +29,7 @@ type GenericMenuConditionalProps =

type GenericMenuProps = GenericMenuCommonProps & GenericMenuConditionalProps & Omit<ComponentProps<typeof MenuV2>, 'children'>;

const GenericMenu = ({ title, icon = 'menu', disabled, onAction, ...props }: GenericMenuProps) => {
const GenericMenu = ({ title, icon = 'menu', disabled, onAction, callbackAction, ...props }: GenericMenuProps) => {
const t = useTranslation();

const sections = 'sections' in props && props.sections;
Expand All @@ -37,7 +38,7 @@ const GenericMenu = ({ title, icon = 'menu', disabled, onAction, ...props }: Gen
const itemsList = sections ? sections.reduce((acc, { items }) => [...acc, ...items], [] as GenericMenuItemProps[]) : items || [];

const disabledKeys = itemsList.filter(({ disabled }) => disabled).map(({ id }) => id);
const handleAction = useHandleMenuAction(itemsList || []);
const handleAction = useHandleMenuAction(itemsList || [], callbackAction);

const hasIcon = itemsList.some(({ icon }) => icon);
const handleItems = (items: GenericMenuItemProps[]) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';

import type { GenericMenuItemProps } from '../GenericMenuItem';

export const useHandleMenuAction = (items: GenericMenuItemProps[], close?: () => void) => {
return useMutableCallback((id) => {
export const useHandleMenuAction = (items: GenericMenuItemProps[], callbackAction?: () => void) => {
return useEffectEvent((id) => {
const item = items.find((item) => item.id === id && !!item.onClick);
if (item) {
item.onClick?.();
close?.();
callbackAction?.();
}
});
};
2 changes: 1 addition & 1 deletion apps/meteor/client/components/ModalBackdrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const ModalBackdrop = ({ children, onDismiss }: ModalBackdropProps): ReactElemen
children={children}
className='rcx-modal__backdrop'
position='fixed'
zIndex={999999}
zIndex={9999}
inset={0}
display='flex'
flexDirection='column'
Expand Down
13 changes: 11 additions & 2 deletions apps/meteor/client/views/room/UserCard/UserCardWithData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,17 @@ const UserCardWithData = ({ username, rid, onOpenUserInfo, onClose }: UserCardWi
return null;
}

return <GenericMenu title={t('More')} key='menu' data-qa-id='menu' sections={menuOptions} placement='bottom-start' />;
}, [menuOptions, t]);
return (
<GenericMenu
title={t('More')}
key='menu'
data-qa-id='menu'
sections={menuOptions}
placement='bottom-start'
callbackAction={onClose}
/>
);
}, [menuOptions, onClose, t]);

const actions = useMemo(() => {
const mapAction = ([key, { content, icon, onClick }]: any): ReactElement => (
Expand Down

0 comments on commit 9c925a3

Please sign in to comment.