Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Now that we have manual scrolling in place, and it turns out to be trivial, we might as well do that when navigating to a fragment on the current page too, because that'd allow us to remove our
onhashchange
event handler. Let's do that in a follow-up.
Comment | File | Size | Author |
---|---|---|---|
#8 | 2713549-followup-8.patch | 558 bytes | Wim Leers |
#4 | 2713549-4.patch | 3.91 KB | Wim Leers |
Comments
Comment #2
Wim LeersComment #3
Wim LeersAnd now with
onhashchange
actually removed.Comment #4
Wim Leersevent.preventDefault()
.Comment #5
Wim LeersThis looks great IMO. One less event handler: much simpler!
But the interdiff in #4 made me realize that we can now structure the code much more elegantly. That's out of scope here, so opened #2713567: Refactor all the controller logic into an actual object: improve understandability/maintainability.
Comment #6
Wim LeersComment #8
Wim LeersDiscovered at #2713567-4: Refactor all the controller logic into an actual object: improve understandability/maintainability that this broke scroll restoration. Due to the scrolling for fragment navigation (
type=intra
) happening before pushing state, so the wrong scroll position is recorded by the browser.Fix attached.
Comment #10
Wim Leers