Page MenuHomePhabricator

MobileSections: Add a new "stickyHeaders" resource Module in ReaderExperiments
Closed, ResolvedPublic5 Estimated Story Points

Description

Background

We will be running an A/B test on the mobile site which looks at opening all sections by default and will compare to the current, closed by default behavior

Requirements
  1. On pageload, all sections should be open by default
  2. As the user scrolls down the page, the section header they are on will be pinned to the top of the page
  3. Tapping on the section header will collapse the section
  4. As the user switches between sections, the section which is scrolled into view will be the one pinned to the top of the page
Design

Prototype: https://vector-2022.vercel.app/sticky-section-headers (note that this prototype shows sections as collapsed by default. We would expect sections to be open by default, but section header behavior is as expected)

Prototype

ScreenRecording2025-10-29at2.58.25PM-ezgif.com-optimize (1).gif (337×160 px, 1 MB)

  • Only h2 headings stick
  • headings should keep their edit icon or lack thereof
  • If a user deep links to a closed H2 section, open it
  • If a user deep links to an h3 or lower section, open it's parent h2 seciton if it isn't already and scroll the target section into view.
    Screenshot 2025-10-29 at 3.09.41 PM.png (1×734 px, 209 KB)
  • open H2 sections should "push up" other open h2 sections when they meet
  • closed h2 sections don't stick
Acceptance Criteria
  • Introduce a new RL module in ReaderExperiments which should be loaded based on the new URL param (per T408045)
  • This module should contain JS/CSS code that enhances the .mf-collapsible-heading elements (created by MobileFrontend) with some additional behavior, similar to https://vector-2022.vercel.app/sticky-section-headers
  • Any changes to MobileFrontend code should be minimal; if we find that more extensive modifications to that code are needed, this task should be re-estimated or broken up
Other considerations

Relying on Intersection Observer may require excluding certain legacy browsers from the experiment.

Event Timeline

egardner set the point value for this task to 5.
egardner moved this task from Needs Refinement to Ready on the Reader Growth Team board.
JScherer-WMF subscribed.

@egardner have a look at the design guidelines and prototype above and let me know what other questions need to be addressed. :)

Change #1200154 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[mediawiki/extensions/ReaderExperiments@master] StickyHeaders: Add new resource module

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

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

Change #1200158 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[mediawiki/extensions/MobileFrontend@master] Add mobileFrontend.section-collapsing-enabled hook

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

Change #1200158 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Add new "readerExperiments.section-toggled" hook

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

Change #1200154 merged by jenkins-bot:

[mediawiki/extensions/ReaderExperiments@master] StickyHeaders: Add new resource modules

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

QA notes:

Once the code has merged, we should check for two different scenarios:

  1. In production / on beta, there should be no change to mobile article pages when the new ?stickyHeaders=1 param is not used
  2. In production / on beta, mobile sections should be expanded and sticky when ?stickyHeaders=1 is used

We don't need to QA the nuances of sticky header behavior here; we'll do that as part of T409325 instead.

QA testing on Beta, 11/6

Using https://en.wikipedia.beta.wmcloud.org/wiki/World as a test article.

  1. In production / on beta, there should be no change to mobile article pages when the new ?stickyHeaders=1 param is not used

✅ Behaves as expected; sections remain collapsed on small viewports in mobile view

  1. In production / on beta, mobile sections should be expanded and sticky when ?stickyHeaders=1 is used

✅ Behaves as expected, sections expand and are sticky using the new param on small viewports in mobile view

@SherryYang-WMF I think this is ready for sign-off– I can do that or you can do so yourself if desired. If you want to verify this on beta, you can follow these steps:

  • Visit this test article on Beta: https://en.wikipedia.beta.wmcloud.org/wiki/World
  • Resize your viewport to be small enough to trigger the existing section collapse behavior (less than 640px wide)
  • Reload the page to confirm that sections collapse
  • Add the ?stickyHeaders=1 url param
  • Reload hte page to confirm that sections expand and exhibit sticky behavior using position:sticky

[11/6 update] tested the following, which are working as expected:

  • Only h2s stick
  • headings keep their edit icon
  • open H2 sections "push up" other open H2s
  • closed H2s don't stick

thanks, looking good!