Alert overlays should display over modals

We were using the same Overlay with no changes, so alerts would display over modals without an overlay behind them
This commit is contained in:
Justin Edmund 2023-07-02 16:18:13 -07:00
parent e43ecb2c00
commit c763a81e21
4 changed files with 15 additions and 7 deletions

View file

@ -7,7 +7,7 @@
width: 100vw; width: 100vw;
top: 0; top: 0;
left: 0; left: 0;
z-index: 31; z-index: 12;
} }
.overlay { .overlay {

View file

@ -22,6 +22,7 @@ const Alert = (props: Props) => {
<AlertDialog.Root open={props.open}> <AlertDialog.Root open={props.open}>
<AlertDialog.Portal> <AlertDialog.Portal>
<Overlay <Overlay
className="alert"
open={props.open} open={props.open}
visible={true} visible={true}
onClick={props.cancelAction} onClick={props.cancelAction}

View file

@ -8,6 +8,10 @@
bottom: 0; bottom: 0;
left: 0; left: 0;
&.alert {
z-index: 11;
}
&.job { &.job {
animation: none; animation: none;
backdrop-filter: blur(5px) saturate(100%) brightness(80%) opacity(1); backdrop-filter: blur(5px) saturate(100%) brightness(80%) opacity(1);

View file

@ -3,6 +3,7 @@ import classNames from 'classnames'
import styles from './index.module.scss' import styles from './index.module.scss'
interface Props { interface Props {
className?: string
visible: boolean visible: boolean
open: boolean open: boolean
onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
@ -13,15 +14,18 @@ const defaultProps = {
} }
const Overlay = React.forwardRef<HTMLDivElement, Props>(function Overlay( const Overlay = React.forwardRef<HTMLDivElement, Props>(function Overlay(
{ visible: displayed, open, onClick }: Props, { className, visible: displayed, open, onClick }: Props,
forwardedRef forwardedRef
) { ) {
const [visible, setVisible] = useState(open) const [visible, setVisible] = useState(open)
const classes = classNames({ const classes = classNames(
[styles.overlay]: true, {
[styles.visible]: displayed, [styles.overlay]: true,
}) [styles.visible]: displayed,
},
className?.split(' ').map((c) => styles[c])
)
useEffect(() => { useEffect(() => {
if (!open) { if (!open) {
@ -38,7 +42,6 @@ const Overlay = React.forwardRef<HTMLDivElement, Props>(function Overlay(
function handleClick(event: React.MouseEvent<HTMLDivElement, MouseEvent>) { function handleClick(event: React.MouseEvent<HTMLDivElement, MouseEvent>) {
// event.stopPropagation() // event.stopPropagation()
console.log('Hey!')
if (onClick) onClick(event) if (onClick) onClick(event)
} }