Skip to content

[Flyout System] Non-managed flyouts have lower z-index than managed flyouts #9160

@tsullivan

Description

@tsullivan

Reported by @tsullivan

Describe the bug

If there is a managed flyout on the screen, and a non-managed flyout is opened in the same coordinates, the non-managed flyout will not be visible because it has a lower z-index.

Impact and severity

Flyout could be not visible, even if it is the latest one to be rendered.

Environment and versions

The Flyout System is currently in an unmerged feature branch.

Minimum reproducible sandbox

interface FlyoutButtonProps {
  title: string;
  mainSize?: 's' | 'm' | 'l' | 'fill';
  flyoutType: 'overlay' | 'push';
  ownFocus?: boolean;
}

const ManagedFlyoutButton: React.FC<FlyoutButtonProps> = (props) => {
  const { title, mainSize, flyoutType, ownFocus = false } = props;
  const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);

  const handleOpenMainFlyout = () => {
    setIsFlyoutVisible(true);
  };

  const mainFlyoutOnClose = () => {
    setIsFlyoutVisible(false);
  };

  return (
    <>
      <EuiText>
        <EuiButton disabled={isFlyoutVisible} onClick={handleOpenMainFlyout}>
          Open managed flyout
        </EuiButton>
      </EuiText>
      {isFlyoutVisible && (
        <EuiFlyout id={`mainFlyout-${title}`} session="start" flyoutMenuProps={{ title }} size={mainSize} type={flyoutType} ownFocus={ownFocus} onClose={mainFlyoutOnClose} >
          <EuiFlyoutBody>
            <EuiText>
              <p>
                <strong>{title} content.</strong>
              </p>
            </EuiText>
          </EuiFlyoutBody>
        </EuiFlyout>
      )}
    </>
  ); // prettier-ignore
};

const NonManagedFlyoutButton: React.FC<FlyoutButtonProps> = (props) => {
  const { title, mainSize: size, flyoutType } = props;
  const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);

  const handleOpenFlyout = () => {
    setIsFlyoutVisible(true);
  };

  const flyoutOnClose = () => {
    setIsFlyoutVisible(false);
  };

  return (
    <>
      <EuiText>
        <EuiButton disabled={isFlyoutVisible} onClick={handleOpenFlyout}>
          Open non-session flyout
        </EuiButton>
      </EuiText>
      {isFlyoutVisible && (
        <EuiFlyout size={size} type={flyoutType} ownFocus={true} onClose={flyoutOnClose} session="never" >
          <EuiFlyoutBody>
            <EuiText>
              <p>
                <strong>{title} content.</strong>
              </p>
            </EuiText>
          </EuiFlyoutBody>
        </EuiFlyout>
      )}
    </>
  ); // prettier-ignore
};

const Demo: React.FC = () => {
  return (
    <>
      <ManagedFlyoutButton title="Managed Flyout" flyoutType="push" mainSize="s" />
      <EuiSpacer size="s" />
      <NonManagedFlyoutButton title="Non-Managed Flyout" flyoutType="overlay" mainSize="m" />
    </>
  ); // prettier-ignore
};

To Reproduce

  1. Open a managed flyout
  2. Open a non-managed flyout in the same coordinates
  3. The non-managed flyout will appear lower than the first, even thought it was the latest one rendered.

Expected behavior

The flyout which is the latest one to be rendered should have the highest z-index.

Screenshots (Optional)

flyout.system.bug.-.nonmanaged.is.lower.mov

Additional context (Optional)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions