fix(theme): prevent background scroll when selecting search history item

pull/5453/head
borntotop 2 weeks ago
parent 3a49d35002
commit 46d6d4e4ea

@ -117,8 +117,13 @@ export function useBodyScrollLock(): WritableComputedRef<boolean> {
const isLocked = shallowRef(false)
let useEvents = false
let scrollY = 0
function lock() {
if (isLocked.value) return
scrollY = window.scrollY
useEvents =
window.innerWidth > document.documentElement.clientWidth &&
!CSS.supports('scrollbar-gutter', 'stable')
@ -130,6 +135,8 @@ export function useBodyScrollLock(): WritableComputedRef<boolean> {
if (!isLocked.value) return
useEvents ? unlockEvents() : unlockOverflow()
isLocked.value = false
window.scrollTo(0, scrollY)
}
onScopeDispose(unlock)

@ -620,3 +620,7 @@
content: '\2060';
color: currentColor;
}
html {
scrollbar-gutter: stable;
}

Loading…
Cancel
Save