Page MenuHomePhabricator

StickyHeaders: legacy parser h3-6 section links obscure content
Closed, ResolvedPublic3 Estimated Story PointsBUG REPORT

Description

Follow-up to T408046: the legacy parser styles for mobile StickyHeaders are missing an adjustment for scroll-margin-top which means the sticky header with the h2 can obscure the start of the section on a link to an h2-h6 header. Additionally, both legacy and parsoid modes produce the wrong scroll position for initial links at load time, and our adjustment was not applying to other elements like div or span with an id attribute.

Adding scroll-margin-top: @spacing-400 to [ id ] within .collapsible-block or the parsoid equivalent is needed but these positions are overridden anyway by pixel offsets in MobileFrontend. Overriding these bad scroll positions by adding a second event listener (for hashchange on window or the wikipage.content hook for initial view) seems to resolve it without any noticeable issues in Chrome or Safari.

Steps to reproduce:

  • go to test page (contents below) with ?stickyHeaders=1&debug=1&useparsoid=0
  • click the "Heading 4b" link on the indented links at top
  • open the "Heading 4b" link in a new tab/window
  • click the "Para 4b" link on the indented links at top
  • open the "Para 4b" link in a new tab/window

Expected results:

  • after scrolling, "Heading 2b" is at top followed by "Heading 4b" or "Para 4b" respectively

Actual results:

  • after scrolling, "Heading 2b" is at top but the expected "Heading 4b" or "Para 4b" are obscured under it

The heading works as expected with useparsoid=1 on the Parsoid styles but the paragraph does not.

Test page: link

QA notes

Testing live master on beta:

  1. Open in new window: legacy parser, with heading fragment
    1. Ensure that "Vocalization" is visible underneath the sticky "Biology"
    2. Scroll back to top and follow the test link back to "#Vocalization"
    3. Ensure that "Vocalization" is again visible underneath the sticky "Biology"
    4. Close the "Biology" section
    5. Scroll back to top and follow the test link back to "#Vocalization"
    6. Ensure that "Vocalization" is again visible underneath the sticky "Biology"
  2. Open in new window: legacy parser, with span fragment
    1. Ensure that "...barking[2][17]" is visible underneath the sticky "Biology"
    2. Scroll back to top and follow the test link back to "#cite_ref-Lloyd1980_2-9"
    3. Ensure that "...barking[2][17]" is visible underneath the sticky "Biology" again
    4. Close the "Biology" section
    5. Scroll back to top and follow the test link back to "#cite_ref-Lloyd1980_2-9"
    6. Ensure that "...barking[2][17]" is visible underneath the sticky "Biology" again
  3. Open in new window: parsoid, with heading fragment
    1. Ensure that "Vocalization" is visible underneath the sticky "Biology"
    2. Scroll back to top and follow the test link back to "Vocalization"
    3. Ensure that "Vocalization" is again visible underneath the sticky "Biology"
    4. Close the "Biology" section
    5. Scroll back to top and follow the test link back to "Vocalization"
    6. Ensure that "Vocalization" is again visible underneath the sticky "Biology"
  4. Open in new window: parsoid, with span fragment
    1. Ensure that "...barking[2][17]" is visible underneath the sticky "Biology"
    2. Scroll back to top and follow the test link back to "#cite_ref-Lloyd1980_2-9"
    3. Ensure that "...barking[2][17]" is visible underneath the sticky "Biology" again
    4. Close the "Biology" section
    5. Scroll back to top and follow the test link back to "#cite_ref-Lloyd1980_2-9"
    6. Ensure that "...barking[2][17]" is visible underneath the sticky "Biology" again

Event Timeline

Change #1202333 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/ReaderExperiments@master] WIP StickyHeaders: scroll-margin-top for legacy parser

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

Change #1202803 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/MobileFrontend@master] Fixes for scrolling to hash fragments in sections

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

Mystery solved -- the MobileFrontend patch fixes a bit in the legacy Toggler.js that was overriding the correct scroll position. Fix should not break current production system while working correctly when position:sticky and scroll-margin-top or scroll-padding-top are in use.

Change #1202803 abandoned by Bvibber:

[mediawiki/extensions/MobileFrontend@master] Fixes for scrolling to hash fragments in sections

Reason:

Abandoning in favor of a targeted workaround in ReaderExperiments 1202333

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

Change #1202333 merged by jenkins-bot:

[mediawiki/extensions/ReaderExperiments@master] StickyHeaders: scroll-margin-top fixes

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

Change #1204928 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/ReaderExperiments@wmf/1.46.0-wmf.2] StickyHeaders: scroll-margin-top fixes

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

mfossati subscribed.

All QA notes pass for me! Tested on a Galaxy S20 Android 11 setup in Firefox.

Change #1204928 merged by jenkins-bot:

[mediawiki/extensions/ReaderExperiments@wmf/1.46.0-wmf.2] StickyHeaders: scroll-margin-top fixes

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

Mentioned in SAL (#wikimedia-operations) [2025-11-13T21:13:15Z] <bvibber@deploy2002> Started scap sync-world: Backport for [[gerrit:1204928|StickyHeaders: scroll-margin-top fixes (T409349)]], [[gerrit:1204700|Reduce number of bucketsizes for MediaViewer (labs, group0) (T372165)]], [[gerrit:1204957|Editcheck: flag suggestions when logging actions (T407170)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-13T21:15:26Z] <bvibber@deploy2002> bvibber, kemayo: Backport for [[gerrit:1204928|StickyHeaders: scroll-margin-top fixes (T409349)]], [[gerrit:1204700|Reduce number of bucketsizes for MediaViewer (labs, group0) (T372165)]], [[gerrit:1204957|Editcheck: flag suggestions when logging actions (T407170)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-13T21:22:13Z] <bvibber@deploy2002> Finished scap sync-world: Backport for [[gerrit:1204928|StickyHeaders: scroll-margin-top fixes (T409349)]], [[gerrit:1204700|Reduce number of bucketsizes for MediaViewer (labs, group0) (T372165)]], [[gerrit:1204957|Editcheck: flag suggestions when logging actions (T407170)]] (duration: 08m 58s)