@wanderview hey Ben! Am I missing something here or is this still an issue? Seems like an important one for mobile especially PWAs, etc. https://bugzilla.mozilla.org/show_bug.cgi?id=251784#c10 …
That page explicitly does document.body.scrollTop = 0, no? The question is whether it does it _before_ or _after_ browsers restore the scroll state. And browsers might differ on that.
-
-
Hey Boris! I left this comment on the bug but that code only runs when the app causes the navigation, not when clicking "back". You can put a breakpoint there to verify. Sorry I should have done a better reduced test case.
-
OK, so I dug more. This is not a normal navigation; it's a pushstate/popstate setup. We attempt to restore the scroll position right after firing the popstate event. The scroll gets clamped to content height, which at this point is 0....
- 7 more replies
New conversation -
-
-
So for example, <body onload="document.documentElement.scrollTop = 0" onunload="console.log('hey')"> will scroll after restoration in Firefox, but before in Chrome. And I haven't been able to figure out what Chrome's heuristics are here, exactly.
-
Doing the scroll off a setTimeout(0) from onload, for example, does run after scroll state restoration. So maybe Chrome restores scroll state "after onload" or something. Firefox restores as we load, so for a long doc you can restore and start reading before it's all parsed.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.