Page MenuHomePhabricator

Section links (HTML #anchors) don't work on mobile + Parsoid + minerva + specific screen sizes
Closed, ResolvedPublic

Description

Fascinating report from enwiki: https://en.wikipedia.org/wiki/Wikipedia:Village_pump_%28technical%29#Redirects_to_sections_not_working

It appears that jumping to a named section doesn't work for users with a specific combination of Mobile View + Minerva Neue + Parsoid + specific screen size.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

I think it needs to be stated explicitly that it's not all section links that don't work but specifically redirects to sections. For example, https://en.wikipedia.org/w/index.php?title=Wikipedia:SOAPBOX will not jump to the section but https://en.wikipedia.org/wiki/Wikipedia:What_Wikipedia_is_not#Wikipedia_is_not_a_soapbox_or_means_of_promotion will.

I can replicate. The redirects are using hash fragments that exist inside content that is hidden until found. Some JavaScript in MobileFrontend is supposed to expand the relevant section and scroll to it.

Either:

  • we forgot to move the logic over from legacy
  • it is being suppressed by something else
  • some kind of race condition
Στο T425290#11884912, ο @Jdlrobson έγραψε:

Some JavaScript in MobileFrontend is supposed to expand the relevant section and scroll to it.

When I scroll down manually, I see that the section is expanded. It is specifically the scrolling that fails.

The target section is correctly kept visible but never scrolled to. sectionCollapsing.js init() never calls expandSectionForTarget() after setup — the hashchange listener exists but fires too late (layout has already shifted from collapsing). The legacy Toggler.js avoids this by calling checkHash() right after setup.

Jdlrobson added a project: patch-welcome.

Change #1282073 had a related patch set uploaded (by HakanIST; author: HakanIST):

[mediawiki/extensions/MobileFrontend@master] sectionCollapsing: Scroll to fragment target on init

https://gerrit.wikimedia.org/r/1282073

Test wiki created on Patch demo by HakanIST using patch(es) linked to this task:
https://da3be33ce1.catalyst.wmcloud.org/w/

Change #1282073 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] sectionCollapsing: Scroll to fragment target on init

https://gerrit.wikimedia.org/r/1282073

Change #1282397 had a related patch set uploaded (by HakanIST; author: HakanIST):

[mediawiki/extensions/MobileFrontend@wmf/1.46.0-wmf.26] sectionCollapsing: Scroll to fragment target on init

https://gerrit.wikimedia.org/r/1282397

Aside: is there a reliable method to access the 'mobile' layout on desktop anymore?

Aside: is there a reliable method to access the 'mobile' layout on desktop anymore?

Browser dev tools mobile emulation is the most reliable way, since it sets both the viewport and user-agent. The en.m. subdomain redirects back to desktop when it detects a desktop user-agent, and ?useformat=mobile gives you the layout but not the full mobile behavior.

Thanks, so only by "tricking" it client-side.

Aside: is there a reliable method to access the 'mobile' layout on desktop anymore?

image.png (1,081×135 px, 28 KB)

?

?useformat=mobile for the casual check.

Yes, it seems that even using all the parameters I've found (e.g. https://en.wikipedia.org/wiki/Wikipedia:SOAPBOX?useparsoid=1&useskin=minerva&mobileaction=toggle_view_mobile ) doesn't reliably cause the server to return the same response.

I have never had an issue with either the toggle, which is toggle_view_mobile, or useformat.

For example, using just parameters I was never able to reproduce the user story from this ticket on desktop.

Change #1282397 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@wmf/1.46.0-wmf.26] sectionCollapsing: Scroll to fragment target on init

https://gerrit.wikimedia.org/r/1282397

Mentioned in SAL (#wikimedia-operations) [2026-05-05T20:46:12Z] <arlolra@deploy1003> Started scap sync-world: Backport for [[gerrit:1282930|hCaptcha: Add diagnostic context to script load error logs (T424496)]], [[gerrit:1282397|sectionCollapsing: Scroll to fragment target on init (T425290)]], [[gerrit:1282804|Errors added below ref list dirty when not responsive (T384599)]]

Mentioned in SAL (#wikimedia-operations) [2026-05-05T20:48:09Z] <arlolra@deploy1003> mpostoronca, h2o, awight, arlolra: Backport for [[gerrit:1282930|hCaptcha: Add diagnostic context to script load error logs (T424496)]], [[gerrit:1282397|sectionCollapsing: Scroll to fragment target on init (T425290)]], [[gerrit:1282804|Errors added below ref list dirty when not responsive (T384599)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be ve

Mentioned in SAL (#wikimedia-operations) [2026-05-05T20:57:11Z] <arlolra@deploy1003> Finished scap sync-world: Backport for [[gerrit:1282930|hCaptcha: Add diagnostic context to script load error logs (T424496)]], [[gerrit:1282397|sectionCollapsing: Scroll to fragment target on init (T425290)]], [[gerrit:1282804|Errors added below ref list dirty when not responsive (T384599)]] (duration: 10m 59s)

Jdlrobson-WMF claimed this task.
Jdlrobson-WMF added a project: Verified.
Jdlrobson-WMF subscribed.

Thank your for the fix and backport. I can verify this is now fixed in production on Parsoid.

Test wiki on Patch demo by HakanIST using patch(es) linked to this task was deleted:

https://da3be33ce1.catalyst.wmcloud.org/w/