mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-30 00:12:56 +00:00
Tweak Dialog to work with showModal and show LockNotifications
This commit is contained in:
@@ -8,18 +8,24 @@ function Dialog({ dismissKey, closeText = 'Close', blocking = false, ...rest })
|
||||
|
||||
useEffect(()=>{
|
||||
if(!dismissKey || !localStorage.getItem(dismissKey)) {
|
||||
blocking ? dialogRef.current?.showModal() : dialogRef.current?.show();
|
||||
setOpen(true);
|
||||
!open && setOpen(true);
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(()=>{
|
||||
if(open && !dialogRef.current?.open){
|
||||
blocking ? dialogRef.current?.showModal() : dialogRef.current?.show();
|
||||
} else {
|
||||
dialogRef.current?.close();
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
const dismiss = ()=>{
|
||||
dismissKey && localStorage.setItem(dismissKey, true);
|
||||
dialogRef.current?.close();
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
if(!open) return null;
|
||||
return (
|
||||
<dialog ref={dialogRef} onCancel={dismiss} {...rest}>
|
||||
<button className='dismiss' onClick={dismiss}>
|
||||
|
||||
Reference in New Issue
Block a user