Skip to content

Commit 49733ea

Browse files
authored
fix: ssr build issue (#46)
* fix: ssr build issue * Create green-onions-protect.md
1 parent c2fbd36 commit 49733ea

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

.changeset/green-onions-protect.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"vaul-vue": patch
3+
---
4+
5+
fix: ssr build issue

packages/vaul-vue/src/controls.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { computed, ref, watch, watchEffect } from 'vue'
22
import type { ComponentPublicInstance, Ref } from 'vue'
3+
import { isClient } from '@vueuse/core'
34
import { dampenValue, getTranslateY, reset, set } from './helpers'
45
import { TRANSITIONS, VELOCITY_THRESHOLD } from './constants'
56
import { useSnapPoints } from './useSnapPoints'
@@ -195,9 +196,8 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
195196
const swipeAmount = drawerRef.value ? getTranslateY(drawerRef.value.$el) : null
196197
const date = new Date()
197198

198-
if (element.hasAttribute('data-vaul-no-drag') || element.closest('[data-vaul-no-drag]')) {
199-
return false;
200-
}
199+
if (element.hasAttribute('data-vaul-no-drag') || element.closest('[data-vaul-no-drag]'))
200+
return false
201201

202202
// Allow scrolling when animating
203203
if (openTime.value && date.getTime() - openTime.value.getTime() < 500)
@@ -424,13 +424,13 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
424424
}
425425

426426
watchEffect(() => {
427-
if (!isOpen.value && shouldScaleBackground.value) {
427+
if (!isOpen.value && shouldScaleBackground.value && isClient) {
428428
// Can't use `onAnimationEnd` as the component will be invisible by then
429429
const id = setTimeout(() => {
430-
reset(document.body);
431-
}, 200);
430+
reset(document.body)
431+
}, 200)
432432

433-
return () => clearTimeout(id);
433+
return () => clearTimeout(id)
434434
}
435435
})
436436

@@ -533,7 +533,7 @@ export function useDrawer(props: UseDrawerProps & DialogEmitHandlers): DrawerRoo
533533
// setting original styles initially
534534
set(document.body, {
535535
background: document.body.style.backgroundColor || document.body.style.background,
536-
});
536+
})
537537
// setting body styles, with cache ignored, so that we can get correct original styles in reset
538538
set(
539539
document.body,

0 commit comments

Comments
 (0)