Page MenuHomePhabricator

Sticky header doesn't show the page title if PAGEBANNER is used
Open, MediumPublic3 Estimated Story PointsBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

What happens?: Two different results: at Txikipedia namespace the sticky header simply doesn't show. At portal namespace the search button appears but the title is absent.

What should have happened instead?: it should have the same behaviour.

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc.:

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
ovasileva triaged this task as Medium priority.Apr 25 2022, 8:41 AM
Jdlrobson removed a project: Wikidata.

I flagged this a while ago. The banner replaces the heading element that we use to trigger the sticky header. If we are to fix this, we'd likely want to make a change inside Wikidata-Page-Banner to make sure the heading there is marked up consistently so that Vector's code picks it up.

bwang removed bwang as the assignee of this task.Jun 3 2022, 7:18 PM
bwang subscribed.

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

[mediawiki/extensions/WikidataPageBanner@master] Add #firstHeading id to banner template

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

Change 802825 merged by jenkins-bot:

[mediawiki/extensions/WikidataPageBanner@master] Add #firstHeading id to banner template

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

Edtadros subscribed.

Test Result - Prod

Status:
Environment: euwiki
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

❓ AC1: @ovasileva , I initially thought that what should happen based on the description is that the sticky header would show. However, since I wasn't able to get it to show (even with the param), I'm no longer sure it should show, but rather that they should "both be the same" and not show. What is the expected result?

Screen Recording 2022-06-16 at 4.17.38 PM.mov.gif (556×1 px, 1 MB)

Screen Recording 2022-06-16 at 4.15.36 PM.mov.gif (556×1 px, 2 MB)

I'm still investigating why the sticky header isnt showing. For the first link in the description (https://eu.wikipedia.org/wiki/Txikipedia:Munduko_zazpi_mirariak) I believe its because the sticky header isnt available in that namespace 104. For the second, (https://eu.wikipedia.org/wiki/Atari:Hezkuntza/Lehiaketak/2022/04) I havent found any obvious reason why its not working. I probably have to setup page banners locally to reproduce and debug.

Edit: Ok I figured it out, my previous patch didnt work because the original #firstHeading element was just hidden with CSS, when it really needs to be removed so that there is a unique element to query for for the sticky intersection element

This comment was removed by bwang.

I think this is okay? I'm not entirely sure what the atari namespace is. For Txikipedia - I suppose it would make sense to have the header appear here for consistency with the main namespace. On the other hand, few of the articles here are long enough to make it particularly useful (by design). @Theklan - any thoughts on this one?

Atari is Portal. Is NS 100, and it's used in all Wikimedia projects. Totally related: T303258, where I explain why portals should be also considered by the design team.

I think that for consistency the sticky header should be shown in any page, regardless of the ns.

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

[mediawiki/skins/Vector@master] WIP: Add collapsed TOC to sticky header

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

I tagged the wrong task, pls ignore the patch above

bwang removed bwang as the assignee of this task.Mar 17 2023, 5:35 PM

It seems like this issue is still present. To summarize my understanding, there was a patch merged into PageBanner, but it didn't actually fix the issue. From @bwang's comment on that patch:

After some more investigating, there are two issues that need to be fixed for this task to work.

  1. Ensure stickyHeader.js can query for a unique "heading" element on pages with page banners. Either by updating the selector used in Vector to be a class, or by adding code to the page banner extension that removes the original h1 element.
  2. The template data for the title is empty when page banner is used, still unsure if that's something that can be updated in page banner extension or can be handled in Vector.

Additionally, the stickyHeader namespace logic is handled client-side with this this line

const allowedNamespaceNumbers = [ 0, 2, 4, 10, 12, 14, 100, 828 ];

which doesn't include namespace 104, for pages like: https://eu.wikipedia.org/wiki/Txikipedia:Munduko_zazpi_mirariak.

Jdrewniak subscribed.

Could someone please give higher priority at fixing this? Banners are widely used on Wikivoyage, and all projects are soon going to be switched to the new Vector skin.

Vector's sticky header seems to work by cloning or parsing the DOM element of the article title, identified by its id ("firstHeader"). This extension blanks the title before the page is rendered and adds another element with the same ID, so in the output page there are two elements with the same ID, the first of which is empty. Instead of blanking the page title, the extension should somehow delete the first element with that ID, or avoid re-using the ID and use CSS to hide the title element when it's in the page header and not the sticky header.

I am not familiar with MW's internals, so the only possible quick-and-dirty fix that I could think of is to have the extension also inject a JS that deletes the first encounter with a "firstHeader" element on page load. I managed to test this partially by adding the following to vector-2022.js in my userspace:

$('#firstHeading').remove();

As a result, the sticky header started showing up, but with the page name blank.

Edited to add: further investigation shows that perhaps the best way to fix that is to avoid blanking the page title. (https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/WikidataPageBanner/+/refs/heads/master/includes/Banner.php#381) and use solely CSS. The code in that conditional block can be replaced with e.g. loading a separate CSS file that hides the title.

Change #1088372 had a related patch set uploaded (by Bmarinov; author: Bmarinov):

[mediawiki/extensions/WikidataPageBanner@master] hide the original title with CSS instead of blanking

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

Thanks for the patch! adding this to our next sprint to make sure we look at it!

the pinning does not behave correctly either:

Screenshot 2024-11-14 at 2.48.01 PM.png (796×1 px, 1 MB)

I took a look at https://gerrit.wikimedia.org/r/c/mediawiki/extensions/WikidataPageBanner/+/1088372 but there are a few problems with that patch.

I've applied a local fix for now:
https://en.wikivoyage.org/wiki/MediaWiki:Vector-2022.css#L-17
I think this should be upstreamed to WikidataPageBanner and Vector 2022.

The sticky header works with this fix, but doesn't have the title. I think this is appropriately fixed by sourcing the title in Vector via a stable JavaScript function in the mediawiki.util library.

@Daggerstab are you still working on this ticket? There is some feedback on the Gerrit patch.

Change #1088372 abandoned by Jdlrobson:

[mediawiki/extensions/WikidataPageBanner@master] hide the original title with CSS instead of blanking

Reason:

@Bmarinov I'm abandoning this patch since there have been no updates in over 3 months, but feel free to restore this if you want to continue! Thanks again for giving this a go!

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