Page MenuHomePhabricator

Table of contents: Strange behaviour when heading is part of a hidden element
Open, LowPublic

Description

On this page: https://meta.wikimedia.org/wiki/Talk:Terms_of_use?useskin=vector-2022 the "Quotations" section, which is hidden in a collapsed block generated by {{Collapse top}}/{{Collapse bottom}} templates, is always marked as active in the TOC, no matter where you scroll.

image.png (2×3 px, 601 KB)

image.png (2×3 px, 568 KB)

Even after clicking on a different section in the TOC, the page jumps there and the TOC momentarily marks the clicked section as active, but upon scrolling "Quotations" becomes active again (and the TOC scrolls to it, which hinders page navigation).

The issue disappears after uncollapsing the hidden content using the "Expand" button or by clicking on the "Quotations" section title in the TOC.

image.png (2×3 px, 524 KB)

image.png (2×3 px, 521 KB)

Event Timeline

Jdlrobson renamed this task from Section hidden in a {{Collapse}} template is stuck marked as active in TOC to Table of contents: Strange behaviour when heading is part of a hidden element.Feb 27 2023, 7:38 PM
Jdlrobson subscribed.

It's also confusing it that clicking the link doesn't auto-expand the section.

On legacy Vector this is a bit of a confusing process too: https://meta.wikimedia.org/wiki/Talk:Terms_of_use?useskin=vector#Quotations doesn't do anything.

Personally I don't think these should be included in the table of contents at all. In mobile web, we do not collapse headings that are not direct children of the parser output element so perhaps we should do something similar here. There's also an argument to be made that collapsed content shouldn't use headings.

It's also confusing it that clicking the link doesn't auto-expand the section.

On legacy Vector this is a bit of a confusing process too: https://meta.wikimedia.org/wiki/Talk:Terms_of_use?useskin=vector#Quotations doesn't do anything.

It does for me, on old and new Vector alike: clicking a link to the section, in the TOC or an external link like yours, expands it. If this doesn't work for you, please try debugging it, the code implementing it is here: https://gerrit.wikimedia.org/g/mediawiki/core/+/130ceaf3a07c56b2b1605b51b65de6fb42430a0d/resources/src/jquery/jquery.makeCollapsible.js#165

Personally I don't think these should be included in the table of contents at all. In mobile web, we do not collapse headings that are not direct children of the parser output element so perhaps we should do something similar here. There's also an argument to be made that collapsed content shouldn't use headings.

I think it'd be a mistake to redesign the table of contents completely again in response to this edge case. I think that it should be easy to handle the section being invisible in the code detecting the currently visible section.

I wouldn't consider this bug to be a part of Local-Wiki-Template-And-Gadget-Issues, since the collapsing code is provided by MediaWiki core and intended to be used on pages exactly in this manner. It's only slightly unusual that a heading is collapsed.

ovasileva moved this task from Incoming to Groomed on the Web-Team-Backlog board.