mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 05:14:06 -06:00
fix(explorer): unintended page scroll when opening low-positioned items in explorer
Replaced scrollIntoView with scrollTop = offsetTop to prevent the entire page from scrolling when an .active item is located near the bottom of the explorer list. Now only the explorer panel scrolls, preserving the main view position.
This commit is contained in:
parent
99414d5419
commit
47654cacbe
@ -222,9 +222,9 @@ async function setupExplorer(currentSlug: FullSlug) {
|
|||||||
explorerUl.scrollTop = parseInt(scrollTop)
|
explorerUl.scrollTop = parseInt(scrollTop)
|
||||||
} else {
|
} else {
|
||||||
// try to scroll to the active element if it exists
|
// try to scroll to the active element if it exists
|
||||||
const activeElement = explorerUl.querySelector(".active")
|
const activeElement = explorerUl.querySelector(".active") as HTMLElement | null
|
||||||
if (activeElement) {
|
if (activeElement) {
|
||||||
activeElement.scrollIntoView({ behavior: "smooth" })
|
explorerUl.scrollTop = activeElement.offsetTop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user