File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,24 @@ const OBSERVER_CONFIG = {
44
44
attributeFilter : [ 'style' , 'class' ]
45
45
}
46
46
47
+ // Query a backdrop for it's default Z-Index from defined CSS styles
48
+ let BASE_ZINDEX = null
49
+ const getModalZIndexOffset = ( ) => {
50
+ if ( BASE_ZINDEX ) {
51
+ return BASE_ZINDEX
52
+ }
53
+ // Create a temporary backdrop element
54
+ const $backdrop = document . createElement ( 'div' )
55
+ $backdrop . className = 'modal-backdrop'
56
+ $backdrop . style . display = 'none'
57
+ document . body . appendChild ( $backdrop )
58
+ // Query the backdrop for it's z-index, or fallback to default of 1040
59
+ BASE_ZINDEX = getCS ( $backdrop ) . zIndex || 1040
60
+ document . body . removeChild ( $backdrop )
61
+ // Return the value
62
+ return BASE_ZINDEX
63
+ }
64
+
47
65
// Modal open count helpers
48
66
const getModalOpenCount = ( ) => parseInt ( getAttr ( document . body , 'data-modal-open-count' ) || 0 , 10 )
49
67
@@ -66,7 +84,6 @@ const getModalMaxZIndex = () => {
66
84
)
67
85
}
68
86
69
- const getModalZIndexOffset = ( ) => getComponentConfig ( NAME , 'zIndexOffset' )
70
87
const getModalZIndexIncrement = ( ) => getComponentConfig ( NAME , 'zIndexIncrement' )
71
88
72
89
// Returns the next z-index to be used by a modal to ensure proper
You can’t perform that action at this time.
0 commit comments