handling unclosable inner attribute
This commit is contained in:
parent
a93c6ea147
commit
480dbc0b41
|
|
@ -16,7 +16,7 @@ export default function Modal({ open, onClose, children, className, id, closeMod
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!unclosable) return;
|
if (!unclosable || unclosable === "false") return;
|
||||||
const { current: currentElement } = modalRef;
|
const { current: currentElement } = modalRef;
|
||||||
currentElement.addEventListener("cancel", (event) => {
|
currentElement.addEventListener("cancel", (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
@ -24,7 +24,12 @@ export default function Modal({ open, onClose, children, className, id, closeMod
|
||||||
}, [unclosable]);
|
}, [unclosable]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<dialog id={id} className={className} ref={modalRef} onClose={onClose}>
|
<dialog
|
||||||
|
id={id}
|
||||||
|
className={className}
|
||||||
|
ref={modalRef}
|
||||||
|
onClose={onClose}
|
||||||
|
unclosable={unclosable ?? "false"}>
|
||||||
{children}
|
{children}
|
||||||
</dialog>
|
</dialog>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user