Skip to content

Commit c5eab4f

Browse files
committed
fix: should not disableBodyScroll when modelValueLocal is false
1 parent db22629 commit c5eab4f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

packages/vue-final-modal/src/components/CoreModal/CoreModal.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,11 @@ const vfmContentEl = ref<HTMLDivElement>()
5555
5656
const { focus, blur } = useFocusTrap(props, { focusEl: vfmRootEl })
5757
const { zIndex, refreshZIndex, resetZIndex } = useZIndex(props)
58-
const { enableBodyScroll, disableBodyScroll } = useLockScroll(props, { lockScrollEl: vfmRootEl })
5958
const { modelValueLocal } = useModelValue(props, emit)
59+
const { enableBodyScroll, disableBodyScroll } = useLockScroll(props, {
60+
lockScrollEl: vfmRootEl,
61+
modelValueLocal,
62+
})
6063
const { emitEvent } = useEvent(emit)
6164
6265
let resolveToggle: (res: string) => void = (noop)

packages/vue-final-modal/src/components/CoreModal/useBodyScrollLock.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ export const enableBodyScroll = (targetElement?: HTMLElement) => {
235235

236236
export function useLockScroll(props: InstanceType<typeof CoreModal>['$props'], options: {
237237
lockScrollEl: Ref<undefined | HTMLElement>
238+
modelValueLocal: Ref<boolean>
238239
}) {
239-
const { lockScrollEl } = options
240+
const { lockScrollEl, modelValueLocal } = options
240241

241242
let _lockScrollEl: HTMLElement
242243
watch(lockScrollEl, (val) => {
@@ -257,6 +258,8 @@ export function useLockScroll(props: InstanceType<typeof CoreModal>['$props'], o
257258
}
258259

259260
function _disableBodyScroll() {
261+
if (!modelValueLocal.value)
262+
return
260263
props.lockScroll && _lockScrollEl
261264
&& disableBodyScroll(_lockScrollEl, {
262265
reserveScrollBarGap: true,

0 commit comments

Comments
 (0)