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

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

Loading…
Cancel
Save