Skip to content

Commit

Permalink
increase ConfirmDialog overlay's z-index to render above popovers
Browse files Browse the repository at this point in the history
  • Loading branch information
chad1008 committed Jan 25, 2022
1 parent 62b8326 commit e52736d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/base-styles/_z-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ $z-layers: (
".reusable-blocks-menu-items__convert-modal": 1000001,
".edit-site-create-template-part-modal": 1000001,

// Note: The ConfirmDialog component's z-index is being set to 1000001 in packages/components/src/confirm-dialog/styles.ts
// because it uses emotion and not sass. We need it to render on top its parent popover.

// ...Except for popovers immediately beneath wp-admin menu on large breakpoints
".components-popover.block-editor-inserter__popover": 99999,
".components-popover.table-of-contents__popover": 99998,
Expand Down
6 changes: 6 additions & 0 deletions packages/components/src/confirm-dialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import { Flex } from '../flex';
import Button from '../button';
import { Text } from '../text';
import { VStack } from '../v-stack';
import * as styles from './styles';
import { useCx } from '../utils/hooks/use-cx';

function ConfirmDialog(
props: WordPressComponentProps< OwnProps, 'div', false >,
Expand All @@ -36,6 +38,9 @@ function ConfirmDialog(
...otherProps
} = useContextSystem( props, 'ConfirmDialog' );

const cx = useCx();
const wrapperClassName = cx( styles.wrapper );

const [ isOpen, setIsOpen ] = useState< boolean >();
const [ shouldSelfClose, setShouldSelfClose ] = useState< boolean >();

Expand Down Expand Up @@ -82,6 +87,7 @@ function ConfirmDialog(
closeButtonLabel={ cancelLabel }
isDismissible={ true }
ref={ forwardedRef }
overlayClassName={ wrapperClassName }
__experimentalHideHeader
{ ...otherProps }
>
Expand Down
16 changes: 16 additions & 0 deletions packages/components/src/confirm-dialog/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* External dependencies
*/
import { css } from '@emotion/react';

/**
* The z-index for ConfirmDialog is being set here instead of in
* packages/base-styles/_z-index.scss, because this component uses
* emotion instead of sass.
*
* ConfirmDialog needs this higher z-index to ensure it renders on top of
* any parent Popover component.
*/
export const wrapper = css`
z-index: 1000001;
`;

0 comments on commit e52736d

Please sign in to comment.