From 7ef74998bea594634e3c88a8a958481667413530 Mon Sep 17 00:00:00 2001 From: devgioele Date: Mon, 23 Oct 2023 06:52:55 +0000 Subject: [PATCH] Fix cropped menu items list (#296) * use floating portal to make menu items list always visible * clarify example of Menu --- src/components/menu/Menu.tsx | 26 ++++++++++++++++++-------- src/examples/Menu.stories.tsx | 15 +++++++++++---- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/components/menu/Menu.tsx b/src/components/menu/Menu.tsx index 6206e57a..67695fc3 100644 --- a/src/components/menu/Menu.tsx +++ b/src/components/menu/Menu.tsx @@ -1,6 +1,12 @@ import { Menu as HeadlessMenu } from '@headlessui/react' import { Fragment, ReactElement, ReactNode, ReactPortal } from 'react' -import { autoUpdate, useFloating, flip, offset } from '@floating-ui/react' +import { + autoUpdate, + useFloating, + flip, + offset, + FloatingPortal, +} from '@floating-ui/react' import classNames from 'classnames' import { useTheme } from '../../framework' import { remToPx } from '../util/remToPx' @@ -74,13 +80,17 @@ export function Menu({ className, children, button, placement }: MenuProps) { }) : button} - - {children} - + {open && ( + + + {children} + + + )} )} diff --git a/src/examples/Menu.stories.tsx b/src/examples/Menu.stories.tsx index 2d3b491f..fb26767e 100644 --- a/src/examples/Menu.stories.tsx +++ b/src/examples/Menu.stories.tsx @@ -36,10 +36,17 @@ const meta = { }, []) return ( -
-
-
- +
+
+
+
+ Container with "overflow: hidden" +
+
+
+ +
+