Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Modal): allow passing z-index to overlay and modal #2662

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/src/components/Modal/Modal/Modal.module.scss
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
$modal-default-z-index: 10000;

.overlay {
--monday-modal-z-index: 10000;
position: fixed;
inset: 0;
background-color: var(--color-surface);
z-index: var(--monday-modal-z-index);
z-index: var(--monday-modal-z-index, $modal-default-z-index);
}

.modal {
--monday-modal-z-index: 10000;
--top-actions-spacing: var(--spacing-large);
--top-actions-width: var(--spacing-xl);
--modal-inline-padding: var(--spacing-xl);

position: fixed;
top: 50%;
left: 50%;
z-index: var(--monday-modal-z-index);
z-index: var(--monday-modal-z-index, $modal-default-z-index);

display: flex;
flex-direction: column;
Expand Down
7 changes: 6 additions & 1 deletion packages/core/src/components/Modal/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const Modal = forwardRef(
container = document.body,
children,
style,
zIndex,
className,
"data-testid": dataTestId
}: ModalProps,
Expand Down Expand Up @@ -88,6 +89,9 @@ const Modal = forwardRef(
? modalAnimationAnchorPopVariants
: modalAnimationCenterPopVariants;

const zIndexStyle = zIndex ? ({ "--monday-modal-z-index": zIndex } as React.CSSProperties) : {};
const modalStyle = { ...zIndexStyle, ...style };

return (
<AnimatePresence>
{show && (
Expand All @@ -105,6 +109,7 @@ const Modal = forwardRef(
className={styles.overlay}
onClick={onBackdropClick}
aria-hidden
style={zIndexStyle}
/>
<FocusLock returnFocus>
<RemoveScroll forwardProps>
Expand All @@ -127,7 +132,7 @@ const Modal = forwardRef(
aria-modal
aria-labelledby={titleId}
aria-describedby={descriptionId}
style={style}
style={modalStyle}
>
{children}
<ModalTopActions
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/components/Modal/Modal/Modal.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,8 @@ export interface ModalProps extends VibeComponentProps {
* Additional inline styles for the modal.
*/
style?: React.CSSProperties;
/**
* The z-index to be used for the modal and overlay.
*/
zIndex?: number;
}
Loading