Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

Cleanup (#110)

Emil Kowalski02709609a910
diff --git a/src/index.tsx b/src/index.tsx
index 345ce20..81d6d01 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;