-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scrolling to hash links is broken on Chrome #4216
Comments
Testing fix now |
You're never going to believe it, but it was introduced in #4155 somehow. |
Makes sense, because it scrolls to the correct position temporary and then returns to 0 |
It's probably something to do with that clientHeight/Width bind, some Chrome edge-case/bug, but no idea how to fix it, maybe there is some other way to do that banner without that bind |
Most of the more complicated stuff with the banner is no longer necessary with the shorter message on mobile that doesn't need to wrap. The whole thing should be able to be replaced with an HTML- and CSS-only banner that swaps out messages with media queries. |
#4219 it looks like it works. |
I think I actually figured the root cause of the issue |
Closed #4219 it was just hiding the issue, need to investigate deeper. |
Before this block of code, the page is correctly scrolled: kit/packages/kit/src/runtime/client/client.js Lines 330 to 334 in cdc32a9
After, it's reset. So it's something to do with the hydration. Trying to create a minimal repro. |
I think the browser tries to scroll, but the max scroll(full page height) changes slightly when hydrated(maybe just 1 pixel) and that causes it, but how to solve it is beyond me. |
Ok I've managed to at least make a simpler repro: https://stackblitz.com/edit/sveltejs-kit-template-default-pm2sdq?file=src%2Froutes%2Ffails.svelte&terminal=dev Visit https://sveltejs-kit-template-default-pm2sdq--3000.local.webcontainer.io/ and try going to |
Just wanted to tell you guys, you are doing great job, I recently tried svelte (kit) and felt like am home 🚀 ( no jsx, simplicity, chrome lighthouse is very happy ..etc) And good luck with this scrolling bug 😊 |
Ok, so the bug isn't visible in the Svelte REPL for obvious reasons, but I think I have a basic understanding of why it's happening: On line 32, in the So we have lots of fixes to choose from:
|
@Rich-Harris I'm on my phone now, but one solution I can think of is to save scroll position(inside client.js) to const before calling new Root I don't it's good to just fix it for the docs site because that bug could be happening on some other sites we don't know about. |
Opened sveltejs/svelte#7341 |
* use src version locally * workaround #4216 * reimplement banner
@Rich-Harris It's happening again for me on the docs site, for ex. link https://kit.svelte.dev/docs/routing#advanced-routing-fallthrough-routes you posted in #4291 (comment) |
Same here! Crazy! 😄 |
@Rich-Harris any idea why this could be happening? because I have none, one workaround I can think of is to check if hash is present and scrollTop is 0, If both are true then we do |
It is working fine for me... Version 1.37.109 Chromium: 100.0.4896.60 (Official Build) (64-bit) |
Didn't work for me(Will attach the right version tomorrow) |
Works for me using Chrome Version 100.0.4896.75 (Official Build) (x86_64) |
Can not reproduce the behavior when default-clicking a link from another page (external or internal), i.e. the links in the Github comments above. However, when middle-mouse-clicking, ctrl-clicking, or pasting the URL into a new tab, the scroll offset doesn't apply just as described in the issue. The same happens when I modify a link in this issue by adding I'm not sure if that's supposed to work like that, due to some browser limitations or something, so I'm not sure that helps. Version 1.37.111 Chromium: 100.0.4896.79 (Official Build) (64-bit) |
Used to be broken in Safari as well. But seems to work from version |
Faced this bug while I was learning sveltekit. Click on this link |
I might have happened on a related issue - I'm finding that Chrome 102.0.5005.63 doesn't scroll to hash when the page is doing an inertial scroll from scrolling with a mouse. Hash links work only when the page has completely stopped moving from inertial scrolling. Scrolling when inertial movement is in effect seems to be working on SvelteKit docs site though. |
Can't reproduce this anymore, therefore closing this. The PR that would fix the underlying issue is sveltejs/svelte#7426 |
Please reopen, middleclicking the link does not scroll to the hash in recent chromium based browsers. |
Having the same problem as well when I paste the hask link in Chrome (Chromium). |
This works now! Thank you :-) |
Describe the bug
Clicking a link like https://kit.svelte.dev/docs/configuration#version should take you to that part of the page. It works in Firefox...
...but not Chrome:
Reproduction
Go to https://kit.svelte.dev/docs/configuration#version in Chrome
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: