66 * Side Public License, v 1.
77 */
88
9- import React , { PropsWithChildren } from 'react' ;
9+ import React , { PropsWithChildren , useMemo } from 'react' ;
1010import { css , cx } from '@emotion/css' ;
11- import type { EuiFlyoutComponentProps } from './flyout.component' ;
1211import { EuiOverlayMask } from '../overlay_mask' ;
1312import { EuiPortal } from '../portal' ;
14- import { useEuiMemoizedStyles , type UseEuiTheme } from '../../services ' ;
13+ import type { EuiFlyoutComponentProps } from './flyout.component ' ;
1514
1615export interface EuiFlyoutOverlayProps extends PropsWithChildren {
1716 hasOverlayMask : boolean ;
1817 maskProps : EuiFlyoutComponentProps [ 'maskProps' ] ;
1918 isPushed : boolean ;
19+ maskZIndex : number ;
2020}
2121
22- const getEuiFlyoutOverlayStyles = ( { euiTheme } : UseEuiTheme ) => {
23- // TODO(tkajtoch): This should likely depend on maskProps.headerZIndexLocation
24- // in cases where the mask has z-index 6000
25- const maskLevel = Number ( euiTheme . levels . flyout ) - 1 ;
26-
27- return {
28- overlayMask : css `
29- /*
30- This needs to have !important to override the default EuiOverlayMask
31- z-index based on the headerZindexLocation prop. Using the style attribute
32- doesn't work since EuiOverlayMask requires a string style prop that
33- causes React errors in the test environment.
34- */
35- z-index : ${ maskLevel } !important ;
36- ` ,
37- } ;
22+ const getEuiFlyoutOverlayStyles = ( zIndex : number ) => {
23+ /*
24+ This needs to have !important to override the default EuiOverlayMask
25+ z-index based on the headerZindexLocation prop. Using the style attribute
26+ doesn't work since EuiOverlayMask requires a string style prop that
27+ causes React errors in the test environment.
28+ */
29+ return css `
30+ z-index : ${ zIndex } !important ;
31+ ` ;
3832} ;
3933
4034/**
@@ -50,21 +44,28 @@ export const EuiFlyoutOverlay = ({
5044 isPushed,
5145 maskProps,
5246 hasOverlayMask,
47+ maskZIndex,
5348} : EuiFlyoutOverlayProps ) => {
54- const styles = useEuiMemoizedStyles ( getEuiFlyoutOverlayStyles ) ;
49+ const styles = useMemo (
50+ ( ) => getEuiFlyoutOverlayStyles ( maskZIndex ) ,
51+ [ maskZIndex ]
52+ ) ;
53+
5554 let content = children ;
5655
5756 if ( ! isPushed || hasOverlayMask ) {
5857 content = < EuiPortal > { content } </ EuiPortal > ;
5958 }
6059
60+ const classes = cx ( maskProps ?. className , styles ) ;
61+
6162 return (
6263 < >
6364 { hasOverlayMask && (
6465 < EuiOverlayMask
6566 headerZindexLocation = "below"
6667 { ...maskProps }
67- className = { cx ( maskProps ?. className , styles . overlayMask ) }
68+ className = { classes }
6869 />
6970 ) }
7071 { content }
0 commit comments