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

Wouldn't scroll to the top after a visit on Firefox if scroll-behavior: smooth is set #426

Open
osvaldasvalutis opened this issue Oct 19, 2021 · 2 comments

Comments

@osvaldasvalutis
Copy link

osvaldasvalutis commented Oct 19, 2021

Turbo wouldn't scroll to the top of the page after page Turbo visit triggered by a link click on Firefox if scroll-behavior: smooth is set on html element. It had been a known issue on Turbolinks as well.

I've been using this workaround:

  document.addEventListener(`turbo:load`, () => {
    document.documentElement.style.scrollBehavior = `smooth`
  })

  document.addEventListener(`turbo:before-visit`, () => {
    document.documentElement.style.scrollBehavior = `unset`
  })
@donovanglover
Copy link

Related: #400

@Muhammad-Sarfaraz
Copy link

Turbo wouldn't scroll to the top of the page after page Turbo visit triggered by a link click on Firefox if scroll-behavior: smooth is set on html element. It had been a known issue on Turbolinks as well.

I've been using this workaround:

  document.addEventListener(`turbo:load`, () => {
    document.documentElement.style.scrollBehavior = `smooth`
  })

  document.addEventListener(`turbo:before-visit`, () => {
    document.documentElement.style.scrollBehavior = `unset`
  })

If you're using Firefox and encountering any scrolling issues with turbo js, you can use above code snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants