From 995e36a9d8a71c37b6874a79f477f081338e08a6 Mon Sep 17 00:00:00 2001 From: Kajetan Szymczak <22811572+KajSzy@users.noreply.github.com> Date: Tue, 1 Oct 2024 09:13:12 +0200 Subject: [PATCH] fix: Fix non-modal drawers without overlay to properly set body pointer events (#460) * fix: Fix non-modal drawers without overlay to properly set body pointer events * Remove window check inside useEffect --- src/index.tsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index bb60332..7d78d7c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -718,6 +718,15 @@ export function Root({ } } + React.useEffect(() => { + if (!modal) { + // Need to do this manually unfortunately + window.requestAnimationFrame(() => { + document.body.style.pointerEvents = 'auto'; + }); + } + }, [modal]); + return ( { - document.body.style.pointerEvents = 'auto'; - }); - } - return null; }