File tree 1 file changed +20
-9
lines changed
packages/react-core/src/next/components/Select
1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ export interface SelectProps extends MenuProps, OUIAProps {
30
30
zIndex ?: number ;
31
31
/** @beta Determines the accessible role of the select. For a checkbox select pass in "menu". */
32
32
role ?: string ;
33
+ /** The container to append the select to. Defaults to 'inline'.
34
+ * If your select is being cut off you can append it to an element higher up the DOM tree.
35
+ * Some examples:
36
+ * appendTo="inline"
37
+ * appendTo={() => document.body}
38
+ * appendTo={document.getElementById('target')}
39
+ */
40
+ appendTo ?: HTMLElement | ( ( ) => HTMLElement ) | 'inline' ;
33
41
}
34
42
35
43
const SelectBase : React . FunctionComponent < SelectProps & OUIAProps > = ( {
@@ -45,6 +53,7 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
45
53
innerRef,
46
54
zIndex = 9999 ,
47
55
role = 'listbox' ,
56
+ appendTo = 'inline' ,
48
57
...props
49
58
} : SelectProps & OUIAProps ) => {
50
59
const localMenuRef = React . useRef < HTMLDivElement > ( ) ;
@@ -115,17 +124,19 @@ const SelectBase: React.FunctionComponent<SelectProps & OUIAProps> = ({
115
124
< MenuContent > { children } </ MenuContent >
116
125
</ Menu >
117
126
) ;
118
- return (
127
+ const popperProps = {
128
+ trigger : toggle ( toggleRef ) ,
129
+ removeFindDomNode : true ,
130
+ popper : menu ,
131
+ isVisible : isOpen ,
132
+ zIndex
133
+ } ;
134
+ return appendTo === 'inline' ? (
119
135
< div ref = { containerRef } >
120
- < Popper
121
- trigger = { toggle ( toggleRef ) }
122
- removeFindDomNode
123
- popper = { menu }
124
- appendTo = { containerRef . current || undefined }
125
- isVisible = { isOpen }
126
- zIndex = { zIndex }
127
- />
136
+ < Popper { ...popperProps } appendTo = { containerRef . current || undefined } />
128
137
</ div >
138
+ ) : (
139
+ < Popper { ...popperProps } appendTo = { appendTo } />
129
140
) ;
130
141
} ;
131
142
You can’t perform that action at this time.
0 commit comments