Skip to content
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

Firefox does not smooth scroll to headings unless the heading or permalink is already visible in the viewport #18

Open
Ambient-Impact opened this issue Jan 26, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Ambient-Impact
Copy link
Member

Ambient-Impact commented Jan 26, 2024

This may be a Firefox bug or something somewhere in our JavaScript codebase is causing it to abort the scroll and instantly snap to the element being focused. This could be related to #11 which is a nasty anchor scroll bug in Chrome.

Details and clues:

  1. Turning JavaScript completely off via dev tools makes it work totally fine, with smooth scroll both when clicking a table of contents link and during back/forward navigation.
  2. If the target is already in the viewport when the link is clicked, smooth scrolling occurs as expected.
  3. If the target isn't in the viewport, it snaps instantly without any smooth scrolling, but seems to stop when the element is in the centre of the screen rather than the element being at the top as it's expected to be.

Solutions

There's an open issue on Bugzilla for what sounds like this problem, so maybe we can just wait for Firefox to fix this, assuming this is the same issue.

Hotwire Turbo

Actually, upon further testing, it seems like this may very well be a bug only when Hotwire Turbo is in use. There's an open issue with a lot of details and potential but hacky workarounds.

Links

@Ambient-Impact Ambient-Impact added the bug Something isn't working label Jan 26, 2024
Ambient-Impact added a commit that referenced this issue Jan 26, 2024
Probably won't use, doesn't quite work and it's re-implementing browser
behaviours - which is a code smell - and it seems like it's actually
probably an issue with Hotwire Turbo.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant