@@ -13,6 +13,7 @@ interface Props {
13
13
coloring ?: 'light' | 'dark' | 'warning' | 'error' ;
14
14
placement ?: 'top' | 'bottom' | 'left' | 'right' ;
15
15
alignment ?: 'center' | 'start' | 'end' ;
16
+ zIndex ?: number | string ;
16
17
hasPointer ?: boolean ;
17
18
offsetFromAnchor ?: number ;
18
19
passthroughProps ?: {
@@ -24,7 +25,7 @@ interface Props {
24
25
escapeCloses ?: boolean ;
25
26
hideWhenAnchorIsOffscreen ?: boolean ;
26
27
allowPlacementAxisChange ?: boolean ;
27
- } ;
28
+ }
28
29
29
30
/**
30
31
* Display a popover. The popover is positioned relative to an anchor element
@@ -36,6 +37,7 @@ export default function Popover({
36
37
padding = 'medium' ,
37
38
active = false ,
38
39
hasPointer = true ,
40
+ zIndex = 'auto' ,
39
41
hideWhenAnchorIsOffscreen = false ,
40
42
allowPlacementAxisChange = true ,
41
43
clickOutsideCloses = true ,
@@ -59,16 +61,19 @@ export default function Popover({
59
61
}
60
62
) ;
61
63
64
+ const bodyStyle = {
65
+ zIndex
66
+ } ;
67
+
62
68
const getContent = ( ) => {
63
69
if ( typeof content === 'function' ) {
64
70
return content ( ) ;
65
71
}
66
72
67
73
return content ;
68
- }
74
+ } ;
69
75
70
76
const onDown = ( e : Event ) => {
71
-
72
77
// Don't call onExit if it wasn't provided.
73
78
if ( ! onExit ) {
74
79
return ;
@@ -87,19 +92,18 @@ export default function Popover({
87
92
}
88
93
89
94
onExit ( ) ;
90
- }
95
+ } ;
91
96
92
97
return (
93
98
< PopoverPrimitive . Root open = { active } >
94
99
< span ref = { triggerRef } style = { { display : 'contents' } } >
95
- < PopoverPrimitive . Trigger asChild >
96
- { children }
97
- </ PopoverPrimitive . Trigger >
100
+ < PopoverPrimitive . Trigger asChild > { children } </ PopoverPrimitive . Trigger >
98
101
</ span >
99
102
< PopoverPrimitive . Portal >
100
103
< PopoverPrimitive . Content
101
- sideOffset = { offsetFromAnchor }
104
+ sideOffset = { offsetFromAnchor }
102
105
className = { bodyClasses }
106
+ style = { bodyStyle }
103
107
onEscapeKeyDown = { escapeCloses && onExit }
104
108
onPointerDownOutside = { clickOutsideCloses && onDown }
105
109
onOpenAutoFocus = { getInitialFocus }
@@ -111,7 +115,14 @@ export default function Popover({
111
115
{ ...passthroughProps }
112
116
>
113
117
{ getContent ( ) }
114
- { hasPointer && < PopoverPrimitive . Arrow width = { 12 } height = { 6 } offset = { 6 } fill = { fill } /> }
118
+ { hasPointer && (
119
+ < PopoverPrimitive . Arrow
120
+ width = { 12 }
121
+ height = { 6 }
122
+ offset = { 6 }
123
+ fill = { fill }
124
+ />
125
+ ) }
115
126
</ PopoverPrimitive . Content >
116
127
</ PopoverPrimitive . Portal >
117
128
</ PopoverPrimitive . Root >
@@ -148,7 +159,11 @@ Popover.propTypes = {
148
159
/**
149
160
* `'medium'`, `'small'`, or `'none'`.
150
161
*/
151
- padding : PropTypes . oneOf ( [ 'medium' , 'small' , 'none' ] ) ,
162
+ padding : PropTypes . oneOf ( [ 'medium' , 'small' , 'none' ] )
163
+ /**
164
+ * z-index of the popover.
165
+ */ ,
166
+ zIndex : PropTypes . number || PropTypes . string ,
152
167
/**
153
168
* Whether or not the popover has a triangle pointer.
154
169
*/
@@ -195,5 +210,5 @@ Popover.propTypes = {
195
210
/**
196
211
* Props to pass directly to popover content options from `@radix-ui/react-popover`.
197
212
*/
198
- passthroughProps : PropTypes . object ,
213
+ passthroughProps : PropTypes . object
199
214
} ;
0 commit comments