/* global document */ import * as React from 'react'; import { Layer, LayersManager, TetherBehavior, TETHER_PLACEMENT, } from 'baseui/layer'; import {useStyletron} from 'baseui'; import {Button} from 'baseui/button'; function Wrapper(props: any) { const [css] = useStyletron(); const {offset, color, children, forwardedRef} = props; return (
{children}
); } const initialState = { isFirstOpen: false, isSecondOpen: false, isFirstMounted: false, isSecondMounted: false, setIsFirstMounted: false, offset1: {top: 0, left: 0}, offset2: {top: 0, left: 0}, }; export default class LayerWithZIndex extends React.Component< {}, typeof initialState > { anchorRef1: any = React.createRef(); popperRef1: any = React.createRef(); anchorRef2: any = React.createRef(); popperRef2: any = React.createRef(); state = initialState; onPopperUpdate: any = (order: any, normalizedOffsets: any) => { this.setState({ [`offset${order}`]: normalizedOffsets.popper, } as any); }; render() { return ( // WARNING: DO NOT COPY THIS EXAMPLE AS IS. THIS EXAMPLE HAS LOCAL LayersManager // JUST FOR DOCUMENTATION EXAMPLE PRESENTATIONAL PURPOSE. // Do not wrap a single component or a part of an application with // LayersManager that has zIndex set to a value other than 'auto' since it // will make all the Layers within its context be on top of other Layers // outside of the local LayersManager (therefore layers provider) added later. // Pass the `zIndex` value to the LayersManager added at the root of your application.
{this.state.isFirstOpen ? ( this.setState({setIsFirstMounted: true}) } onUnmount={() => this.setState({setIsFirstMounted: false}) } > this.onPopperUpdate(1, ...args) } placement={TETHER_PLACEMENT.right} > ) : null}

{this.state.isSecondOpen ? ( this.setState({isSecondMounted: true}) } onUnmount={() => this.setState({isSecondMounted: false}) } > this.onPopperUpdate(2, ...args) } placement={TETHER_PLACEMENT.right} > ) : null}
Element with z-index set
); } }