Page MenuHomePhabricator

Table of contents should not be displayed when an editor puts __NOTOC__ in the parser content
Closed, ResolvedPublic2 Estimated Story Points

Description

Spun out of T297611

When determining whether or not to show the new ToC, the same rules that govern the current ToC should be applied. If the ToC is currently hidden via magic words like __NOTOC__ or by other means, it should remain hidden in this update.

Developer notes

  • If NOTOC is present in the page, SkinMustache still gets the data needed to render the table of contents. We'll need to change the core code, to provide some indication that the table of contents was disabled to support this change.
  • Skin::getSectionsData should return null when NOTOC is used. Attached POC patch uses OutputPage::isTOCEnabled in core - returns false when NOTOC magic word is present. See thread in #content-transformers channel re: OutputPage::isTOCEnabled usage https://wikimedia.slack.com/archives/C024Z8K9CAU/p1642090580148800

QA steps

NOTE: Someone will need to enable the table of contents on the beta cluster before this can be tested.

With the new Vector skin:

QA Results - Beta

QA Results - Prod

ACStatusDetails
1T298796#7706513
2T298796#7671121

Event Timeline

Change 753785 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/core@master] POC: check if TOC is enabled when using NOTOC magic word.

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

cjming updated the task description. (Show Details)
cjming added a subscriber: cjming.

In order for Vector to know if the data is empty or not, would we also have to update Skin::getSectionsData to be protected instead of private? Or create another method like Skin::isTOCEmpty ?

hi @bwang -- if we output null for array-sections in Skin::getTemplateData when __NOTOC__ (via OutputPage::isTOCEnabled) is set -- we'll see that it's null in $parentData in SkinVector::getTemplateData too.

{{#array-sections}} will be skipped in the case of null, so no PHP should be required

e.g.

{{#array-sections}}
There is a TOC in this page.
{{/array-sections}}
{{^array-sections}}
There is no TOC in this page.
{{/array-sections}}
Jdlrobson updated the task description. (Show Details)

Blocked on T297611 and enabling that on the beta cluster. Will move to QA when possible.

Change 753785 merged by jenkins-bot:

[mediawiki/core@master] Check if TOC is enabled when using NOTOC magic word to return sections data or not.

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

Edtadros added a subscriber: Edtadros.

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

[mediawiki/skins/Vector@master] Ensure TOC is not shown when section data is empty

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

Change 757037 had a related patch set uploaded (by Clare Ming; author: Bernard Wang):

[mediawiki/core@master] Add additional layer of nesting to TOC data to better support rendering of TOC with mustache templates

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

Change 757390 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[mediawiki/skins/Vector@master] Update TOC template with data wrapper

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

Change 757390 abandoned by Clare Ming:

[mediawiki/skins/Vector@master] Update TOC template and logic

Reason:

spoke with Bernard - he already has a patch going so abandoning in favor of https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/756715

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

Change 757037 merged by jenkins-bot:

[mediawiki/core@master] Add additional layer of nesting to TOC data to better support rendering of TOC with mustache templates

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

Change 756715 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Rely on core TOC data to show the TOC in Vector

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

Test Result - Beta

Status: ❓ Need Clarification
Environment: beta
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

With the new Vector skin:

❓ AC1: Visit https://en.wikipedia.beta.wmflabs.org/wiki/Table_of_contents_test_page?tableofcontents=1 and confirm the table of contents is visible in the sidebar
@Jdlrobson, the Contents element is there, but there are no sections. Is this sufficient for this test?

Screen Shot 2022-02-02 at 5.50.47 AM.png (695×904 px, 294 KB)

✅ AC2: Visit https://en.wikipedia.beta.wmflabs.org/wiki/Table_of_contents_NOTOC_test_page?tableofcontents=1 and confirm the table of contents does not display in the sidebar or the article

Screen Shot 2022-02-02 at 5.50.53 AM.png (695×904 px, 297 KB)

Edtadros updated the task description. (Show Details)

Test Result - Beta
Status: ✅ (but another bug should be taken care of)
Environment: beta
OS: Windows 11 Family 21H2
Browser: Vivaldi
Device: Desktop
Emulated Device:NA

Test Artifact(s):

QA Steps
With the new Vector skin:

✅ AC1: Visit https://en.wikipedia.beta.wmflabs.org/wiki/Table_of_contents_test_page?tableofcontents=1 and confirm the table of contents is visible in the sidebar
TOC is there as long as long as I don't try to display the left bar at the same time, even after scrolling (see screenshot #2). I think a new task should be creates for this bug.

Capture d’écran 2022-02-10 212710.png (965×1 px, 316 KB)

Capture d’écran 2022-02-10 212819.png (964×1 px, 153 KB)

✅ AC2: Visit https://en.wikipedia.beta.wmflabs.org/wiki/Table_of_contents_NOTOC_test_page?tableofcontents=1 and confirm the table of contents does not display in the sidebar or the article

Capture d’écran 2022-02-10 212952.png (963×1 px, 296 KB)

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

With the new Vector skin:

✅ AC1: Visit https://en.wikipedia.beta.wmflabs.org/wiki/Table_of_contents_test_page?tableofcontents=1 and confirm the table of contents is visible in the sidebar

Screen Shot 2022-02-13 at 6.35.59 PM.png (1×1 px, 239 KB)

Test Result - Prod

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

Test Artifact(s):

QA Steps

With the new Vector skin:

✅ AC1: Visit https://en.wikipedia.org/wiki/Dog?tableofcontents=1 and confirm the table of contents is visible in the sidebar

Screen Shot 2022-02-13 at 6.45.26 PM.png (1×1 px, 453 KB)

✅ AC2: Visit https://en.wikipedia.beta.wmflabs.org/wiki/Table_of_contents_NOTOC_test_page?tableofcontents=1 and confirm the table of contents does not display in the sidebar or the article

Screen Shot 2022-02-13 at 6.50.53 PM.png (1×1 px, 207 KB)