Page MenuHomePhabricator

Fix layout shift on parsoid section collapsing
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

Followup to https://phabricator.wikimedia.org/T363934
During work on T363934 it was found that the arrow icons needs to be rendered serverside in order to prevent the headings from shifting as the JS kicks in. This is consistent with how icons are handled in the original section collapsing implementation. This is necessary due to the fact that section collapsing applies to all headings with the highest level on a given page (i.e. if a page has h2s and h3s, collapsing will apply to all h2s).

User story

As a reader on office wikimedia and other projects using Parsoid I want to be able to collapse sections without layout shifts as the page loads

Requirements

  • Parsoid section collapsing behavior matches non parsoid
  • doesnt have layoutshift as JS loads in

Requirement

Ensure that Parsoid section collapsing behavior matches the non-Parsoid implementation, preventing layout shifts as JavaScript loads. The arrow icons should be rendered server-side to ensure stability during page load.

BDD

Feature: Fix Layout Shift on Parsoid Section Collapsing

  Scenario: Collapse sections without layout shift in Parsoid
    Given the user views a page using Parsoid with collapsible sections
    When the page loads
    Then no layout shift should occur as JavaScript initializes
    And the section collapsing behavior should match the non-Parsoid implementation

Test Steps

Test Case 1: Verify Section Collapsing Without Layout Shift on Parsoid

  1. Visit a page using Parsoid with collapsible sections.
  2. AC1: Confirm that no layout shift occurs as JavaScript loads.
  3. AC2: Confirm that section collapsing behavior matches the non-Parsoid implementation.

Rollback plan

None necessary due to feature flag.

This task was created by Version 1.0.0 of the Web team task template

QA Results - Beta

ACStatusDetails
1T367240#10128083
2T367240#10128083

Event Timeline

Jdlrobson triaged this task as Medium priority.Jun 11 2024, 11:22 PM
Jdlrobson awarded a token.
Jdlrobson moved this task from Backlog to Q4 (April-July) on the Readers Essential Work 2025 board.
SToyofuku-WMF set the point value for this task to 3.Aug 8 2024, 5:45 PM

We talked about this in estimation and realized that, since we need to server side render some of this and currently the logic for determining which headers are collapsible lives in JS, that we need to pull that logic out of the JS and move it to the backend. Once we've got the collapsible header logic in PHP, we can hold space for the icons using CSS or render them on the backend

SToyofuku-WMF raised the priority of this task from Medium to High.Aug 8 2024, 10:19 PM
SToyofuku-WMF added a subscriber: ovasileva.

Gonna raise the priority on this one to reflect the above - @ovasileva @Jdlrobson feel free to override me while I'm out

Conclusion is this will probably need to be done on backend. I would love to chat with Bernard about whether a frontend solution is possible and what the trade offs would be.

Moving this to blocked until Bernard is back.

@bwang I came up with this CSS-only solution while working on T371539

Change #1068063 had a related patch set uploaded (by Bernard Wang; author: Bernard Wang):

[mediawiki/extensions/MobileFrontend@master] Move section collapsing logic to serverside

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

Change #1068864 had a related patch set uploaded (by Bernard Wang; author: Bernard Wang):

[mediawiki/extensions/MobileFrontend@master] Fix icon reflow

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

Change #1068864 merged by jenkins-bot:

[mediawiki/extensions/MobileFrontend@master] Fix icon reflow

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

Change #1068063 abandoned by Bernard Wang:

[mediawiki/extensions/MobileFrontend@master] Move section collapsing logic to serverside

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

Edtadros subscribed.

Test Result - Beta

Status: ✅ PASS
Environment: Beta
OS: macOS
Browser: Chrome
Device: MS MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Verify Section Collapsing Without Layout Shift on Parsoid

  1. Visit a page using Parsoid with collapsible sections.
  2. AC1: Confirm that no layout shift occurs as JavaScript loads.

See AC2 below

  1. AC2: Confirm that section collapsing behavior matches the non-Parsoid implementation.

screenshot.mov.gif (1×498 px, 664 KB)

Looks good! Confirmed no more page jumping