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

Turbo scrolls to first empty id #201

Closed
jmfederico opened this issue Mar 9, 2021 · 2 comments
Closed

Turbo scrolls to first empty id #201

jmfederico opened this issue Mar 9, 2021 · 2 comments

Comments

@jmfederico
Copy link

jmfederico commented Mar 9, 2021

I have noticed the following behavior:

If a site has html tags with empty id attributes like this: id="", then turbo will scroll to that element after a new page navigation occurs.

Leaving aside the fact that there should be no empty id's, maybe Turbo should only scroll to elements that actually have an id?

@sebyx07
Copy link

sebyx07 commented May 6, 2021

Temporary fix:

document.addEventListener("turbo:before-render", () =>{
  document.querySelectorAll("[id]").forEach((el) => {
    if(el.id === "") el.removeAttribute("id");
  })
});

@dhh
Copy link
Member

dhh commented Aug 24, 2021

This has been fixed.

@dhh dhh closed this as completed Aug 24, 2021
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