Page MenuHomePhabricator

Section collapsing should not apply to certain pages
Open, LowPublic5 Estimated Story Points

Description

Related: T407815: Section collapsing applies to namespaces it should not apply to in mobile

Background

Under a very specific set of circumstances, we're ending up different treatments for articles in Parsoid and legacy parser when content is not arranged under h2 subheadings. This is due to the code not actually checking if the heading is an h2 explicitly, and looking at top level sections, which this h3 appears to erroneously be This is not supported behaviour.

In addition to this the English Wikitionary community in T376446 has requested that section collapsing does not apply to pages with only one section. This seems a reasonable request that should apply to all pages.

User story

As a reader of wikis on mobile once parsoid has rolled out, I want my reading experience to be consistent, and to understand the structure of an article based on its sections

Requirements

  • Update MobileFrontend's section collapsing logic for legacy and parsoid so that it doesn't apply in the following circumstances:
  • Only one heading in the page e.g. https://ru.m.wikipedia.org/wiki/%D0%97%D0%B0%D0%B1%D0%B5%D0%BB%D0%B8%D0%BD
  • The first heading in the page is not an h2.
  • The entire page is wrapped in a DIV
  • When section collapsing does not apply to a page, no section collapse arrows should apply.
  • The new treatment should be cache resistant by being an additive change - existing CSS should be preserved and new CSS using a new class on the HTML, parser or body element should be utilized. For example a class "mf-section-collapsing-disabled" should be added to the page and any CSS should target this element e.g. .mf-section-collapsing-disabled .section-heading .indicator { margin-right: 0;} to disable existing margin on indicator element for example.

Acceptance criteria

  • All QA steps pass.

QA

For QA in beta cluster, for the following URLs:
Confirm section collapsing is available on the following URLS:

Confirm section collapsing is NOT available on the following URLS:

For QA in production:

BDD

Feature: Section collapsing logic updates
  Scenario: Enable section collapsing when conditions are met
    Given a page with multiple h2 headings not wrapped in a `<div>`
    When the page is rendered
    Then section collapsing should be available

  Scenario: Disable section collapsing for pages with one heading
    Given a page with only one heading
    When the page is rendered
    Then section collapsing should not be available
    And the "mf-section-collapsing-disabled" class should be applied

  Scenario: Disable section collapsing when the first heading is not an h2
    Given a page where the first heading is not an h2
    When the page is rendered
    Then section collapsing should not be available
    And the "mf-section-collapsing-disabled" class should be applied

  Scenario: Disable section collapsing when the entire page is wrapped in a `<div>`
    Given a page where all content is wrapped in a `<div>`
    When the page is rendered
    Then section collapsing should not be available
    And the "mf-section-collapsing-disabled" class should be applied

Test Steps

Beta Cluster

Test Case 1: Verify section collapsing is available

  1. Visit the following URLs:

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase1?useparsoid=0
https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase1?useparsoid=1

  1. Verify that section collapsing is available on these pages.
  2. AC1: Section collapsing is enabled.

Test Case 2: Verify section collapsing is not available

  1. Visit the following URLs:

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase2?useparsoid=0
https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase2?useparsoid=1
https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase3?useparsoid=0
https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase3?useparsoid=1
https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase4?useparsoid=0
https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase4?useparsoid=1

  1. Verify that section collapsing is not available on these pages.
  2. AC2: Section collapsing is disabled, and the “mf-section-collapsing-disabled” class is applied.

Production

Test Case 3: Verify section collapsing is not available in production

  1. Visit the following URLs:

https://sv.m.wikivoyage.org/w/index.php?title=Bispg%C3%A5rden&useparsoid=1
https://sv.m.wikivoyage.org/w/index.php?title=Bispg%C3%A5rden&useparsoid=0

  1. Verify that section collapsing is not available on these pages.
  2. AC3: Section collapsing is disabled, and the “mf-section-collapsing-disabled” class is applied.

Rollback plan

Rollback - this does impact both legacy and parsoid HTML. It should be safe to roll back provided we add a new class to the page to identify pages where section collapsing is not available.

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

My take is that we shouldn't contort the collapsing behaviour to accommodate poorly structured HTML. So the top-level H3s shouldn't be collapsible.

Jdlrobson renamed this task from Sections are collapsible in parsoid when they shouldn't be to Section collapsing should not apply to certain pages.Oct 10 2024, 1:03 AM
Jdlrobson added a project: MobileFrontend.
Jdlrobson updated the task description. (Show Details)

Olga: this is also envisioned as a suitable onboarding task.

Best prod test cases are most pages on swedish wikivoyage

It would also be good to do something with cases like https://ru.m.wikipedia.org/wiki/Википедия:К_удалению/21_октября_2020 where the <div> prevents collapsible headings but users also do not have any visible TOC on mobile resolutions. My previous patch fixing this sort of issue was rejected by @Jdlrobson but the issue still persists.

Change #1101572 had a related patch set uploaded (by LorenMora; author: LorenMora):

[mediawiki/extensions/MobileFrontend@master] Add getFirstHeading to MakeSectionsTransform

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

Maybe out of scope of this task, but one related idea I had is that local admins should be able to define a list of section names that would not be ‘counted’ towards collapsing threshold. Like ‘See also’, ‘External links’, etc. if community so decides. There are usually standardised sections for linking to related articles, for example, and those should not be weighted the same as regular sections on the page.

This would be helpful in cases like https://ru.m.wikipedia.org/wiki/Коротков where there is effectively one actual section but the page would get collapsed nonetheless. Or, for articles, in cases like https://ru.wikipedia.org/wiki/Кондратьев,_Александр_Иванович_(Герой_Социалистического_Труда) where the only text section is ‘Biography’ and other is just ‘References’.

Change #1101572 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Add getFirstHeading to MakeSectionsTransform

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

Change #1101931 had a related patch set uploaded (by LorenMora; author: LorenMora):

[mediawiki/extensions/MobileFrontend@master] WIP: Adding conditional logic for making sections

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

If we can wrap this up in some from next week (merging after Monday to make sure it doesnt get deployed that would be great).

Feel free to descope this as necessary and create follow up tasks if there are still outstanding todos.

Have a great holiday!

We will be putting this ticket on hold due to added complexity.

@SToyofuku-WMF Let's rebase and recheck the current unmerged patch. Then it should be set to merge.

After discussing this and the complexities we uncovered while working on this, we are descoping this for now. @SToyofuku-WMF to write a more comprehensive write up at their leisure.

Change #1101931 abandoned by Jdlrobson:

[mediawiki/extensions/MobileFrontend@master] Update getFirstHeading function to target new heading markup

Reason:

Per discussion with Steph and Loren we are going to roll back these changes and revisit them at a later date.

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

Change #1109502 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/MobileFrontend@master] Revert "Add getFirstHeading to MakeSectionsTransform"

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

Change #1109502 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Revert "Add getFirstHeading to MakeSectionsTransform"

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

Jdlrobson-WMF raised the priority of this task from Low to Medium.Jan 21 2025, 10:05 PM
Jdlrobson-WMF subscribed.

I think this will be a blocker for parsoid roll out so increasing to medium.

@Jdlrobson/@SToyofuku-WMF, I was only able to see section collapsing disabled on AC2 with the testcase 3 URLs. Also, It appears that only some of the sections were not collapsible in prod.

Status:❓Need More Info / ❌ FAIL
Environment: Beta, Prod
OS: macOS
Browser: Chrome
Device: MA

Test Case 1: Verify section collapsing is available

  1. Visit the following URLs:
  2. Verify that section collapsing is available on these pages.
  3. ✅ AC1: Section collapsing is enabled.

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase1?useparsoid=0

screenshot 66.mov.gif (1×778 px, 434 KB)

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase1?useparsoid=1
screenshot 67.mov.gif (1×778 px, 432 KB)

Test Case 2: Verify section collapsing is not available

  1. Visit the following URLs:
  2. Verify that section collapsing is not available on these pages.
  3. ❌ AC2: Section collapsing is disabled, and the “mf-section-collapsing-disabled” class is applied.

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase2?useparsoid=0

screenshot 68.mov.gif (922×1 px, 267 KB)

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase2?useparsoid=1
screenshot 69.mov.gif (922×1 px, 265 KB)

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase3?useparsoid=0
screenshot 70.mov.gif (922×1 px, 246 KB)

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase3?useparsoid=1
screenshot 71.mov.gif (922×1 px, 223 KB)

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase4?useparsoid=0
screenshot 72.mov.gif (922×1 px, 252 KB)

https://en.m.wikipedia.beta.wmflabs.org/wiki/T374883/testcase4?useparsoid=1
screenshot 73.mov.gif (922×1 px, 222 KB)

Test Case 3: Verify section collapsing is not available in production

  1. Visit the following URLs:
  2. Verify that section collapsing is not available on these pages.
  3. ❓ AC3: Section collapsing is disabled, and the “mf-section-collapsing-disabled” class is applied.

https://sv.m.wikivoyage.org/w/index.php?title=Bispg%C3%A5rden&useparsoid=1

screenshot 74.mov.gif (922×1 px, 1 MB)

https://sv.m.wikivoyage.org/w/index.php?title=Bispg%C3%A5rden&useparsoid=0
screenshot 75.mov.gif (922×1 px, 499 KB)

Code was merged and reverted in same deploy so you can skip QA on this one Edward.

Jdlrobson-WMF lowered the priority of this task from Medium to Low.May 29 2025, 10:35 PM
Jdlrobson-WMF removed the point value 5 for this task.
Jdlrobson-WMF moved this task from Incoming/Inbox to Needs Refinement on the Reader Growth Team board.

The Reader Growth team is currently working on an experiment around defaulting mobile sections to expanded instead of defaulting them to collapsed. We're going to launch an A/B test around this for a subset of users in a few weeks. Based on the data we get, we may decide to move away from auto-collapsing mobile sections in general.

We can revisit this bug once we have some initial findings here.

HSwan-WMF set the point value for this task to 5.Wed, Nov 26, 5:50 PM

@SherryYang-WMF would love to chat about whether it makes sense to treat this as a blocker for roll out or not. Have added to our next 1-on-1.