[go: up one dir, main page]

Page MenuHomePhabricator

Make MobileFrontend signal the user is viewing the mobile version of the site
Closed, ResolvedPublic

Description

Background

There are a number of RL modules that use the wgMFMode client-side global configuration variable as a proxy for "is the user viewing the mobile version of the site", e.g.

var isMobile = mw.config.get( 'wgMFMode' ) !== null;

Open Questions

  1. Is this an acceptable use of wgMFMode?
    • If so, could this be document where it's added to the output so that it doesn't get removed?
    • If not, could we introduce a new stable variable to use, e.g. wgMFIsMobile?

Event Timeline

Jdlrobson subscribed.

Could this be done using a class on the body element?

Could this be done using a class on the body element?

Yes, provided that it was considered stable (i.e. it would have to go through some deprecation process to change its name/value(s) or remove it).

Is this an acceptable use of wgMFMode?

In answer to this, I think no. wgMFMode was meant to tell the client whether the user was in beta mode or normal mobile mode. It got repurposed to mean mobile.

Yes, provided that it was considered stable (i.e. it would have to go through some deprecation process to change its name/value(s) or remove it).

I think to make it stable ideally we'd use a mw.util function allowing for us to change the class name in future.

Perhaps this work could be a precursor to feature management. "Mobile mode" is actually a feature, that's enabled in a certain situation (You are on a mobile device).

Perhaps we could use this as task to add some lightweight foundations for feature management in core (T242835)?

  1. A mediawiki.util function to check if features are enabled:
mw.util.isFeatureEnabled('mobile')

Used by WikimediaEvents
Internally checks for classes on the body, that are added by the feature management system. e.g. mobile and visualeditor features may have the associated classes mw-feature-enabled-mobile and mw-feature-enabled-visualeditor

  1. MobileRequirement and MobileFeature

Utilized by MobileFrontend to check the requirement is met and to add it to the page.

Change 782758 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/extensions/MobileFrontend@master] Add a body class indicating mobilefrontend is active

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

Change 782758 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Add a body class indicating mobilefrontend is active

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

To spell out the solution: that patch added mw-mf as a class on the body element, which will only be present if the site is in MobileFrontend mode (regardless of skins, etc). Anything that wants a binary "is MF active" can check for that, and TemplateStyles can hang themselves from it.

Change 809619 had a related patch set uploaded (by Phuedx; author: Phuedx):

[mediawiki/extensions/MobileFrontend@master] Hooks: Add wgMFIsActive client-side config variable

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

Jdlrobson triaged this task as Medium priority.Jul 5 2022, 7:10 PM

I've discussed this task further with @Jdlrobson and we both agree that:

  1. The use of mw.config.get( 'wgMFMode' ) !== null only signals that the MobileFrontend extension is active
  2. Adding another config variable (e.g. wgMFIsActive) only replicates this signal
  3. The PHP and JS Metrics Platform Clients should be updated to reflect the above (already captured in T311629: Change agent_client_platform_family context attribute values)
  4. The JS Metrics Platform Client should be updated to provided a bucketed viewport width

I'm being bold and closing this task as Resolved.

Change 809619 abandoned by Phuedx:

[mediawiki/extensions/MobileFrontend@master] Hooks: Add wgMFIsActive client-side config variable

Reason:

Per https://phabricator.wikimedia.org/T299772#8109026

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