Skip to content

Commit

Permalink
fix: use vueuse scroll lock on root
Browse files Browse the repository at this point in the history
  • Loading branch information
Elliot-Alexander committed Jan 14, 2024
1 parent bf25589 commit 12d47ca
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-moles-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"vaul-vue": patch
---

Use vueuse's scoll lock to prevent scroll issues on ios
1 change: 1 addition & 0 deletions packages/vaul-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"release": "pnpm run build-only"
},
"dependencies": {
"@vueuse/core": "^10.7.2",
"radix-vue": "^1.2.5",
"vue": "^3.4.5"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/vaul-vue/src/DrawerRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { DialogRoot } from 'radix-vue'
import { provideDrawerRootContext } from './context'
import { type DialogProps, useDrawer } from './controls'
import { watch } from 'vue'
import { useScrollLock } from '@vueuse/core'
const open = defineModel<boolean>('open', {
default: false
Expand All @@ -28,6 +29,8 @@ const {
dismissible
} = provideDrawerRootContext(useDrawer())
const preventScroll = useScrollLock(document, false)
if (props.snapPoints) {
snapPoints.value = props.snapPoints
activeSnapPoint.value = props.snapPoints[0]
Expand Down Expand Up @@ -75,6 +78,9 @@ const handleOpenChange = (o: boolean) => {
}
watch(open, (o) => handleOpenChange(o), { immediate: true })
watch([isOpen, hasBeenOpened], ([openValue, hasOpenedValue]) => {
preventScroll.value = openValue || hasOpenedValue
})
</script>

<template>
Expand Down
32 changes: 32 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 12d47ca

Please sign in to comment.