Closed Bug 1444170 Opened 6 years ago Closed 6 years ago

Do not fire document.body.scrollTop = 0 when navigating back

Categories

(Core :: DOM: Navigation, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox60 --- affected

People

(Reporter: kbrosnan, Unassigned)

References

(Blocks 1 open bug)

Details

1. Go here: http://scroll-back-bug.surge.sh/
2. Scroll to bottom click link
3. Click back button

Expected: 

Scrolls back to bottom (this is what Chrome, Safari, and Edge do)

Actual: 

Stays scrolled to top

> Hey Boris, thanks for responding! So, the thing is that code only runs when the app changes the URL, not when you click "back", you can verify that by putting a breakpoint on that line. It will run when you click the link, but not when you click "back".
> Also where should I be commenting? This is behavior is inconsistent between browsers and seems like a problem for PWAs and all single page apps.
See bug 251784 comment 10 through 13 context.
That line is not executed on back in this case.  See discussion at https://twitter.com/HenrikJoreteg/status/969685986237079552 (have to dig into the threads).

But the summary is: This code does not run on back.  What runs is code that on popstate sticks a <script> in the DOM which then async generates the DOM of the page.  We do scroll restoration right after firing popstate, per spec, which is before the new content is generated.
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.