From f23743eff8f1d6c9b9337a2f8ea29308a4a290d3 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 22 Jan 2024 16:13:42 +0100 Subject: [PATCH] fix: showModal not supported by old browser --- src/components/modal/lunatic-modal.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/modal/lunatic-modal.tsx b/src/components/modal/lunatic-modal.tsx index 76e96a2db..6d5f2ef80 100644 --- a/src/components/modal/lunatic-modal.tsx +++ b/src/components/modal/lunatic-modal.tsx @@ -12,8 +12,13 @@ function LunaticModal(props: LunaticComponentProps<'ConfirmationModal'>) { const dialogRef = useRef(null); useEffect(() => { - // Browser behaviour is different for dialog displayed with this API, it creates de dialog with backdrop - dialogRef.current?.showModal(); + try { + // Browser behaviour is different for dialog displayed with this API, it creates de dialog with backdrop + dialogRef.current?.showModal(); + } catch (e) { + // Browser may not support showModal(), try to add open attribute + dialogRef.current?.setAttribute('open', ''); + } }, []); const handleClose = () => {