From 9db5e7bda682eb034c1efb0998db9256d4b150c7 Mon Sep 17 00:00:00 2001 From: Titani Labaj <39532947+tlabaj@users.noreply.github.com> Date: Tue, 26 Mar 2024 17:20:51 -0400 Subject: [PATCH] feat(Dropdown): Added support for setting height for dropdown (#10149) * feat(Dropdown): Added support for setting height for dropdown * apply isScrollable to menu if maxMenuHeight or menuHeight is defined --- .../src/components/Dropdown/Dropdown.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/react-core/src/components/Dropdown/Dropdown.tsx b/packages/react-core/src/components/Dropdown/Dropdown.tsx index 92c513c7815..b136fd501ef 100644 --- a/packages/react-core/src/components/Dropdown/Dropdown.tsx +++ b/packages/react-core/src/components/Dropdown/Dropdown.tsx @@ -65,6 +65,10 @@ export interface DropdownProps extends MenuProps, OUIAProps { zIndex?: number; /** Additional properties to pass to the Popper */ popperProps?: DropdownPopperProps; + /** Height of the dropdown menu */ + menuHeight?: string; + /** Maximum height of dropdown menu */ + maxMenuHeight?: string; } const DropdownBase: React.FunctionComponent = ({ @@ -83,6 +87,8 @@ const DropdownBase: React.FunctionComponent = ({ zIndex = 9999, popperProps, onOpenChangeKeys = ['Escape', 'Tab'], + menuHeight, + maxMenuHeight, ...props }: DropdownProps) => { const localMenuRef = React.useRef(); @@ -138,6 +144,8 @@ const DropdownBase: React.FunctionComponent = ({ }; }, [isOpen, menuRef, toggleRef, onOpenChange, onOpenChangeKeys]); + const scrollable = maxMenuHeight !== undefined || menuHeight !== undefined || isScrollable; + const menu = ( = ({ shouldFocusToggleOnSelect && toggleRef.current.focus(); }} isPlain={isPlain} - isScrollable={isScrollable} + isScrollable={scrollable} {...props} {...ouiaProps} > - {children} + + {children} + ); return (