Scrolling doesn't work as expected in mobile. Due to several issues here, we likely want to rethink how it works.
Issue 1: Mobile: Section links jump to wrong spot when a section is open
I happened to notice that the section links in the Safari mobile view navigated to a seemingly random place within the article if the page had already been loaded and one or more preceding sections had previously been opened. In the preceding case, trying the "Australia" links immediately after the "sight vocabulary" links caused this behavior (e.g., by clicking on one of the "sight vocabulary" links, then clicking the "back" button twice [once to return to the top of the page and once to go back to the sandbox] and then immediately clicking on one of the Australia links). I'm wondering if may be because the section's physical location is being calculated assuming that all sections are collapsed. Once I collapsed all above sections and tried again, the section link sent me to the correct place.
Issue 2
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.