From 02709609a9107a3404fe2284063c806e2307e685 Mon Sep 17 00:00:00 2001 From: Emil Kowalski <36730035+emilkowalski@users.noreply.github.com> Date: Fri, 22 Sep 2023 20:56:13 +0200 Subject: [PATCH] Cleanup (#110) --- src/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index 345ce206..81d6d01b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -281,6 +281,16 @@ function Root({ } } + React.useEffect(() => { + // Clean up the wrapper styles in case the drawer has been unmounted without closing it + const wrapper = document.querySelector('[vaul-drawer-wrapper]'); + if (wrapper) { + return () => { + reset(wrapper); + }; + } + }, []); + React.useEffect(() => { function onVisualViewportChange() { if (!drawerRef.current) return;