I think it would be great addition to the visit method to have an option to preserve the scroll.
I’m currently implementing it like this:
const scrollY = window.scrollY
Turbo.visit(location, { action: "replace" })
document.addEventListener("turbo:load", () => {
window.scrollTo(0, scrollY)
}, { once: true })
I was thinking it could be beneficial to add this as an option to the .visit call like:
Turbo.visit(location, { action: "replace", scroll: "preserve" })