Update: Add modal prop to dropdown-menu

This commit is contained in:
danidfra 2024-09-27 21:17:48 -03:00
parent d8a3affe59
commit d77ca78a3a
1 changed files with 4 additions and 2 deletions

View File

@ -19,6 +19,7 @@ export type Menu = Array<MenuItem | null>;
interface IDropdownMenu { interface IDropdownMenu {
children?: React.ReactElement; children?: React.ReactElement;
modal?: boolean;
disabled?: boolean; disabled?: boolean;
items: Menu; items: Menu;
onClose?: () => void; onClose?: () => void;
@ -35,6 +36,7 @@ const listenerOptions = supportsPassiveEvents ? { passive: true } : false;
const DropdownMenu = (props: IDropdownMenu) => { const DropdownMenu = (props: IDropdownMenu) => {
const { const {
children, children,
modal = false,
disabled, disabled,
items, items,
onClose, onClose,
@ -90,7 +92,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
* On mobile screens, let's replace the Popper dropdown with a Modal. * On mobile screens, let's replace the Popper dropdown with a Modal.
*/ */
const handleOpen = () => { const handleOpen = () => {
if (userTouching.matches) { if (userTouching.matches || modal) {
dispatch( dispatch(
openModal('ACTIONS', { openModal('ACTIONS', {
status: filteredProps.status, status: filteredProps.status,
@ -111,7 +113,7 @@ const DropdownMenu = (props: IDropdownMenu) => {
const handleClose = () => { const handleClose = () => {
(refs.reference.current as HTMLButtonElement)?.focus(); (refs.reference.current as HTMLButtonElement)?.focus();
if (userTouching.matches) { if (userTouching.matches || modal) {
dispatch(closeModal('ACTIONS')); dispatch(closeModal('ACTIONS'));
} else { } else {
closeDropdownMenu(); closeDropdownMenu();