Page MenuHomePhabricator

[SPIKE] Kartographer uses MobileFrontend hook for section expansion, not applying to Parsoid
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

Many projects have been using parsoid now.
While doing some code cleanup in MobileFrontend I noticed Kartographer makes use of the mobileFrontend.section-toggled hook which is not present in the Parsoid version and in the legacy parser marked as Internal for use inside ExternalGuidance.
https://gerrit.wikimedia.org/g/mediawiki/extensions/Kartographer/+/2914baaa1260d7cf3cf9961fcb3e7503c028478e/modules/mapframe/mapframe.js#102

Is this still needed? If so could you provide context on what bug it is addressing so the #readers-growth team can consider whether to ?

TODO

  • Determine if Kartographer still needs it (And if there is a bug in production that has resurfaced relating to this)
    • alternative method found using InteractionObserver, and merged
  • If needed, update the documentation that Kartographer uses the hook and add it to the Parsoid sectionCollapsing code.
    • n/a as not needed
  • If not remove hook from code.
    • done

Event Timeline

Hook may have already been removed due to a patch Eric made the other day.

it is mentioned right above there right ?

// Special case for collapsed maps.
// When the container is initially hidden Leaflet is not able to
// calculate the expected size when visible. We need to force
// updating the map to the new container size on `expand`.

// do the same for mobile sections

So kartographer (or rather Leaflet) needs to calculate its own size and when it is not rendered, it cannot do so (because its parent has no dimensions). So it has to force (a redo of) this calculation step when it has been made visible.

This is probably only for dynamic maps on things like wikivoyage, where we draw an inline dynamic map

@TheDJ I saw the comment but this hook has never been executed in Parsoid which has been live on wikivoyage for quite some time and nobody reported an issue, so we're questioning whether it's still needed. Can we replicate the original bug?

Is this the same issue (I can't reliably replicate it)?
https://en.wikivoyage.org/wiki/San_Carlos_de_Bariloche

Screenshot 2025-11-25 at 10.50.10 AM.png (822×493 px, 149 KB)

Could IntersectionObserver be used here instead to address this issue?

Is this the same issue (I can't reliably replicate it)?
https://en.wikivoyage.org/wiki/San_Carlos_de_Bariloche

Screenshot 2025-11-25 at 10.50.10 AM.png (822×493 px, 149 KB)

Yes it is.

Could IntersectionObserver be used here instead to address this issue?

Not sure

HSwan-WMF renamed this task from Kartographer uses MobileFrontend hook for section expansion, not applying to Parsoid to [SPIKE] Kartographer uses MobileFrontend hook for section expansion, not applying to Parsoid.Nov 26 2025, 5:47 PM
HSwan-WMF set the point value for this task to 2.

Change #1224637 had a related patch set uploaded (by Matthias Mullie; author: Matthias Mullie):

[mediawiki/extensions/Kartographer@master] Use intersection observer to invalidate size

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

Change #1224650 had a related patch set uploaded (by Matthias Mullie; author: Matthias Mullie):

[mediawiki/extensions/MobileFrontend@master] Remove mobileFrontend.section-toggled hook

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

Could IntersectionObserver be used here instead to address this issue?

Not sure

I tested with a (local version of) https://en.wikivoyage.org/wiki/San_Carlos_de_Bariloche, and it seems to work well enough with a simple intersection observer instead of relying on that hook.
Patches in CR.

Does the bug still exist in production? If so, what are the steps to replicate the bug? I ask because I'm not able to replicate the bug on mobile view (locally or production wiki) using the example page, https://en.wikivoyage.org/wiki/San_Carlos_de_Bariloche
For local setup, I configured LocalSettings to retrieve content from the Wikivoyage API ($wgMFMwApiContentProviderBaseUri = "https://en.wikivoyage.org/w/api.php").

Screenshot 2025-11-25 at 10.50.10 AM.png (822×493 px, 149 KB)

Note you can replicate this locally with latest version of MobileFrontendContentProvider and http://localhost:8888/w/index.php/San_Carlos_de_Bariloche?mfproviderproject=wikivoyage&useparsoid=1

Without bug: I shoulds see no flash.

Thanks @Jdlrobson-WMF ! My viewport was too small to see the bug in production. Now, I notice the bug when sections are initially expanded (640px and larger) and collapsed (639px and smaller). The map is broken between 481-1119px on Minerva mobile view with Parsoid enabled (Parsoid appears to be the default for Wikivoyage in production)

FYI I wasn't really able to reproduce through above scenario, but loading it on my phone (iPhone; width around 390px) with sections collapsed consistently showed the issue upon expanding the section.

Change #1224637 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Use intersection observer to invalidate size

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

Change #1224650 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Remove mobileFrontend.section-toggled hook

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

The issue is consistently reproducible in wmf.10 on a real mobile device (e.g. iPhone) - some other examples:
https://en.wikivoyage.org/wiki/Manchester/Castlefield-Petersfield
https://en.wikivoyage.org/wiki/Altrincham

Checked on enwikivoyage wmf.11 - issue is fixed.

bvibber updated the task description. (Show Details)
bvibber subscribed.

Confirmed that todo list is all complete and fix is live for enwikivoyage. Signing off and closing. :)