I figured I'd open a new bug for this since I think the issue is related to SSR vs CSR anchor scrolling.
I'm also running into this behavior when I directly navigate to a URL with an anchor that is meant to scroll the page down to that id. I haven't found any svelte:window scroll binding (or any scroll binding) in the code on the page in question. But no doubt there is some in other components loaded on other pages. Or, possibly in 3rd party libs like Superforms/Popper.
page loads and immediately begins scrolling to #pricing (I have smooth scrolling enabled)
2-500ms later, the page immediately sets the window position back to the top
The workaround mentioned above (and pasted below) isn't ideal since it happens after the improper Svelte scrolling and causes visual jitter on the page. But it's better than nothing.
Including @jjagielka workaround from the linked PR:
// from https://github.com/themesberg/flowbite-svelte/pull/923/files
onMount(() => {
// Workaround until https://github.com/sveltejs/kit/issues/2664 is fixed
if (typeof window !== 'undefined' && window.location.hash) {
const deepLinkedElement = document.getElementById(window.location.hash.substring(1))
if (deepLinkedElement) {
window.setTimeout(() => deepLinkedElement.scrollIntoView(), 100)
}
}
})
I figured I'd open a new bug for this since I think the issue is related to SSR vs CSR anchor scrolling.
I'm also running into this behavior when I directly navigate to a URL with an anchor that is meant to scroll the page down to that id. I haven't found any
svelte:window
scroll binding (or any scroll binding) in the code on the page in question. But no doubt there is some in other components loaded on other pages. Or, possibly in 3rd party libs like Superforms/Popper.The behavior I see is:
The workaround mentioned above (and pasted below) isn't ideal since it happens after the improper Svelte scrolling and causes visual jitter on the page. But it's better than nothing.
Including @jjagielka workaround from the linked PR:
Originally posted by @coryvirok in https://github.com/sveltejs/kit/issues/2664#issuecomment-1854622252