From OTRS
Ticket: https://ticket.wikimedia.org/otrs/index.pl?Action=AgentTicketZoom;TicketID=10866024
Hello,
I have a technical question concerning the mobile version of Wikipedia, using the Chrome browser for Android Oreo: when I click on a hyperlink on a Wikipedia page to go on a new page (that opens in the same browser window), and then use the back button of the phone (lower right), I often don't get back to the same location of the Wikipedia page where the hyperlink is located, but higher up or lower down on the page. Why is this? Is there a remedy for this?
Many thanks for your help,
MaxChrome for Android ... hyperlink and then go back don't get back to the exact location of the hyperlink but higher up in the page ...
Replication steps
This one seems easy to replicate in an emulated Chrome window or Android
- Visit https://en.m.wikipedia.org/wiki/Ozone_layer?oldid=871775124
- Expand section "Depletion"
- Scroll to "Regulation" and click "Hydrochlorofluorocarbon"
- Click back button
- Expect: To see the link "Hydrochlorofluorocarbon"
- Actual: No sign of the link "Hydrochlorofluorocarbon"
Developer notes
This doesn't appear to be related to any tinkering with window.scrollTop but is to do with the fact that sections are collapsed by default. In fact if I disable JS this works just as expected.
The method expandStoredSections inside Toggler ensures that the section that contains the link is opened, but it opens after the browser has restored the scroll position of the page.
The only way to solve this and retain the toggle behaviour would be to capture the scroll position on every link click and ensure that expandStoredSection restores the scroll position.
There is a good opportunity here to refactor Toggler to not have the responsibility of scroll position. This code should live in Minerva as Minerva should be responsible for the scroll position at all times.