22 <template v-if =" activatedOnce " >
33 <Teleport to =" body" >
44 <GDialogOverlay
5+ ref =" overlay"
56 :active =" isActive"
67 :deactivating =" deactivating"
78 :active-z-index =" activeZIndex"
1112 <Transition name =" dialog-transition" >
1213 <div
1314 v-show =" isActive"
14- ref =" frame "
15+ ref =" contentFrame "
1516 :class =" classes"
1617 :style =" styles"
1718 >
3233
3334<script lang="ts">
3435import {
35- defineComponent , computed , ref , watch ,
36+ defineComponent , computed , ref , watch , onBeforeUnmount ,
3637} from ' vue'
3738
3839import { useStackable } from ' ../composable/stackable'
3940import { useLazyActivation } from ' ../composable/lazyActivation'
40-
41- import { disableScroll , enableScroll } from ' ../helper/scroll.helper'
41+ import { useScroll } from ' ../composable/scroll'
4242
4343import GDialogOverlay from ' ./GDialogOverlay.vue'
4444import GDialogContent from ' ./GDialogContent.vue'
@@ -120,6 +120,11 @@ export default defineComponent({
120120 emits: [' update:modelValue' ],
121121
122122 setup(props , { emit }) {
123+ const contentFrame = ref <Element >()
124+ const overlay = ref <InstanceType <typeof GDialogOverlay >>()
125+
126+ const overlayElement = computed <Element | undefined >(() => overlay .value ?.$el as Element )
127+
123128 const onClickOutside = () => {
124129 if (! props .persistent ) {
125130 emit (' update:modelValue' , false )
@@ -130,12 +135,11 @@ export default defineComponent({
130135 computed (() => props .modelValue ),
131136 )
132137
133- const frame = ref (null )
134138 const { activeZIndex } = useStackable ({
135139 activeElSelector: ' .q-dialog-frame--active' ,
136140 stackMinZIndex: 200 ,
137141 isActive ,
138- content: frame ,
142+ content: contentFrame ,
139143 })
140144
141145 const classes = computed (() => [
@@ -149,14 +153,23 @@ export default defineComponent({
149153 zIndex: activeZIndex .value ,
150154 }))
151155
156+ const { enableScroll, disableScroll } = useScroll ({
157+ overlay: overlayElement ,
158+ content: contentFrame ,
159+ })
160+
152161 watch (isActive , (active ) => {
153162 if (active ) {
154- disableScroll (props . hideScrollbar )
163+ disableScroll ()
155164 } else {
156165 enableScroll ()
157166 }
158167 })
159168
169+ onBeforeUnmount (() => {
170+ enableScroll ()
171+ })
172+
160173 return {
161174 onClickOutside ,
162175 activatedOnce ,
@@ -165,7 +178,8 @@ export default defineComponent({
165178 deactivating ,
166179 classes ,
167180 styles ,
168- frame ,
181+ contentFrame ,
182+ overlay ,
169183 }
170184 },
171185})
0 commit comments