From d77ca78a3a2f7ecbe69214efbcf4b01f27f7cde1 Mon Sep 17 00:00:00 2001 From: danidfra Date: Fri, 27 Sep 2024 21:17:48 -0300 Subject: [PATCH] Update: Add modal prop to dropdown-menu --- src/components/dropdown-menu/dropdown-menu.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/dropdown-menu/dropdown-menu.tsx b/src/components/dropdown-menu/dropdown-menu.tsx index 7bdaff994..1d21d5829 100644 --- a/src/components/dropdown-menu/dropdown-menu.tsx +++ b/src/components/dropdown-menu/dropdown-menu.tsx @@ -19,6 +19,7 @@ export type Menu = Array; interface IDropdownMenu { children?: React.ReactElement; + modal?: boolean; disabled?: boolean; items: Menu; onClose?: () => void; @@ -35,6 +36,7 @@ const listenerOptions = supportsPassiveEvents ? { passive: true } : false; const DropdownMenu = (props: IDropdownMenu) => { const { children, + modal = false, disabled, items, onClose, @@ -90,7 +92,7 @@ const DropdownMenu = (props: IDropdownMenu) => { * On mobile screens, let's replace the Popper dropdown with a Modal. */ const handleOpen = () => { - if (userTouching.matches) { + if (userTouching.matches || modal) { dispatch( openModal('ACTIONS', { status: filteredProps.status, @@ -111,7 +113,7 @@ const DropdownMenu = (props: IDropdownMenu) => { const handleClose = () => { (refs.reference.current as HTMLButtonElement)?.focus(); - if (userTouching.matches) { + if (userTouching.matches || modal) { dispatch(closeModal('ACTIONS')); } else { closeDropdownMenu();