From 543439c5b789e0676396957d857624704b82a6c5 Mon Sep 17 00:00:00 2001 From: MariaAga Date: Fri, 1 Sep 2023 14:02:36 +0200 Subject: [PATCH] feat(select next): add appendTo --- .../src/next/components/Select/Select.tsx | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/packages/react-core/src/next/components/Select/Select.tsx b/packages/react-core/src/next/components/Select/Select.tsx index b06cdb4e3c9..5d9f1dde7d0 100644 --- a/packages/react-core/src/next/components/Select/Select.tsx +++ b/packages/react-core/src/next/components/Select/Select.tsx @@ -30,6 +30,14 @@ export interface SelectProps extends MenuProps, OUIAProps { zIndex?: number; /** @beta Determines the accessible role of the select. For a checkbox select pass in "menu". */ role?: string; + /** The container to append the select to. Defaults to 'inline'. + * If your select is being cut off you can append it to an element higher up the DOM tree. + * Some examples: + * appendTo="inline" + * appendTo={() => document.body} + * appendTo={document.getElementById('target')} + */ + appendTo?: HTMLElement | (() => HTMLElement) | 'inline'; } const SelectBase: React.FunctionComponent = ({ @@ -45,6 +53,7 @@ const SelectBase: React.FunctionComponent = ({ innerRef, zIndex = 9999, role = 'listbox', + appendTo = 'inline', ...props }: SelectProps & OUIAProps) => { const localMenuRef = React.useRef(); @@ -115,17 +124,19 @@ const SelectBase: React.FunctionComponent = ({ {children} ); - return ( + const popperProps = { + trigger: toggle(toggleRef), + removeFindDomNode: true, + popper: menu, + isVisible: isOpen, + zIndex + }; + return appendTo === 'inline' ? (
- +
+ ) : ( + ); };