From 15646771983cbf815d8769d8b9b691072883cf58 Mon Sep 17 00:00:00 2001 From: maro Date: Wed, 11 Jan 2023 16:09:32 +0900 Subject: [PATCH] fix: react-modal unmount bug - ref: https://github.com/reactjs/react-modal/issues/808 --- src/components/Modal/index.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/Modal/index.tsx b/src/components/Modal/index.tsx index 0eaf4622..5e6f930b 100644 --- a/src/components/Modal/index.tsx +++ b/src/components/Modal/index.tsx @@ -139,6 +139,18 @@ function Modal({ }; }, [resizeTrigger]); + useEffect(() => { + const removeClassName = () => { + if (!document.querySelector(".ReactModal__Content")) { + document.body.classList.remove("ReactModal__Body--open"); + } + }; + return () => { + removeClassName(); + setTimeout(removeClassName, MODAL_CLOSE_TIMEOUT_MS + 100); + }; + }, [isOpen]); + return (