Skip to content

armgit / vaul

Public Imported from GitHub
0

A drawer component for React.

format (#148)

Emil Kowalski35310deeb782
diff --git a/src/use-position-fixed.ts b/src/use-position-fixed.ts
index 88491f4..3a17f53 100644
--- a/src/use-position-fixed.ts
+++ b/src/use-position-fixed.ts
@@ -17,7 +17,7 @@ export function usePositionFixed({
function setPositionFixed() {
// If previousBodyPosition is already set, don't set it again.
- if (previousBodyPosition === null) {
+ if (previousBodyPosition === null && isOpen) {
previousBodyPosition = {
position: document.body.style.position,
top: document.body.style.top,
@@ -98,7 +98,7 @@ export function usePositionFixed({
} else {
restorePositionSetting();
}
- }, [isOpen]);
+ }, [isOpen, hasBeenOpened]);
return { restorePositionSetting };
}