diff --git a/src/client/theme-default/components/VPLocalSearchBox.vue b/src/client/theme-default/components/VPLocalSearchBox.vue index 5458615f0400..d1f9a7d90150 100644 --- a/src/client/theme-default/components/VPLocalSearchBox.vue +++ b/src/client/theme-default/components/VPLocalSearchBox.vue @@ -6,6 +6,7 @@ import { onKeyStroke, useEventListener, useLocalStorage, + useScrollLock, useSessionStorage } from '@vueuse/core' import Mark from 'mark.js' @@ -16,6 +17,7 @@ import { createApp, markRaw, nextTick, + onBeforeUnmount, onMounted, ref, shallowRef, @@ -36,8 +38,9 @@ const emit = defineEmits<{ (e: 'close'): void }>() -const el = shallowRef() -const resultsEl = shallowRef() +const el = shallowRef() +const resultsEl = shallowRef() +const body = shallowRef() /* Search */ @@ -312,6 +315,20 @@ useEventListener('popstate', (event) => { emit('close') }) +/** Lock body */ +const isLocked = useScrollLock(body) + +onMounted(() => { + body.value = document.body + nextTick(() => { + isLocked.value = true + }) +}) + +onBeforeUnmount(() => { + isLocked.value = false +}) + function formMarkRegex(terms: Set) { return new RegExp( [...terms]