Page MenuHomePhabricator

[Regression, production] Vector 2022 TOC disappears, becomes "undefined" after saving an edit with DiscussionTools, VisualEditor
Closed, ResolvedPublic

Description

Vector 2022 TOC disappears, becomes "undefined" after saving an edit with DiscussionTools.

Tested on https://en.wikipedia.beta.wmflabs.org/wiki/User_talk:Yatu

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

QA Results - Beta

ACStatusDetails
1T326682#8518315

QA Results - Prod

ACStatusDetails
1T326682#8518320

Event Timeline

The same problem happens with VisualEditor.

It's caused by change https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/869854. The code in tableOfContents.js depends on the TableOfContents template to output a single root node (jQuery's html() method only returns the HTML of the first node in the collection). After that change, it outputs 2 text nodes and an element node instead.

I started trying to fix this by passing around the original template output as a jQuery collection, instead of converting it to HTML (which should improve performance as well). That fixes this problem, but only reveals further issues – the whole DOM has changed, so this causes the TOC header ("Contents") to be lost, and highlighting active sections no longer works either.

Incomplete patch in case it helps:

diff --git a/resources/skins.vector.es6/tableOfContents.js b/resources/skins.vector.es6/tableOfContents.js
index a8568762..c145c2aa 100644
--- a/resources/skins.vector.es6/tableOfContents.js
+++ b/resources/skins.vector.es6/tableOfContents.js
@@ -417,11 +417,11 @@ module.exports = function tableOfContents( props ) {
 	 */
 	function reloadTableOfContents( sections ) {
 		if ( sections.length < 1 ) {
-			reloadPartialHTML( TOC_ID, '' );
+			$( document.getElementById( TOC_ID ) ).empty();
 			return;
 		}
 		mw.loader.using( 'mediawiki.template.mustache' ).then( () => {
-			reloadPartialHTML( TOC_ID, getTableOfContentsHTML( sections ) );
+			$( document.getElementById( TOC_ID ) ).empty().append( getTableOfContentsHTML( sections ) );
 			// Reexpand sections that were expanded before the table of contents was reloaded.
 			reExpandSections();
 			// Initialize Collapse toggle buttons
@@ -446,7 +446,7 @@ module.exports = function tableOfContents( props ) {
 	 * Generates the HTML for the table of contents.
 	 *
 	 * @param {Section[]} sections
-	 * @return {string}
+	 * @return {jQuery}
 	 */
 	function getTableOfContentsHTML( sections ) {
 		return getTableOfContentsListHtml( getTableOfContentsData( sections ) );
@@ -456,7 +456,7 @@ module.exports = function tableOfContents( props ) {
 	 * Generates the table of contents List HTML from the templates
 	 *
 	 * @param {Object} data
-	 * @return {string}
+	 * @return {jQuery}
 	 */
 	function getTableOfContentsListHtml( data ) {
 		// @ts-ignore
@@ -470,7 +470,7 @@ module.exports = function tableOfContents( props ) {
 			TableOfContents__line: compiledTemplateTocLine // eslint-disable-line camelcase
 		};
 
-		return compiledTemplateBody.render( data, partials ).html();
+		return compiledTemplateBody.render( data, partials );
 	}
 
 	/**
matmarex renamed this task from Vector 2022 TOC disappears, becomes "undefined" after saving an edit with DiscussionTools to Vector 2022 TOC disappears, becomes "undefined" after saving an edit with DiscussionTools, VisualEditor.Tue, Jan 10, 11:40 PM
matmarex removed matmarex as the assignee of this task.
matmarex edited projects, added Editing-team (Tracking); removed Editing-team.
ovasileva triaged this task as Unbreak Now! priority.Wed, Jan 11, 12:05 AM
ovasileva added a subscriber: ovasileva.

(This is on mediawiki.org in production so likely a regression on the current train. Perhaps relates to work in https://gerrit.wikimedia.org/r/q/topic:parser-toc so adding content transformers too)

Jdlrobson renamed this task from Vector 2022 TOC disappears, becomes "undefined" after saving an edit with DiscussionTools, VisualEditor to [Regression, production] Vector 2022 TOC disappears, becomes "undefined" after saving an edit with DiscussionTools, VisualEditor.Wed, Jan 11, 1:39 AM
Jdlrobson added a project: Regression.

(This is on mediawiki.org in production so likely a regression on the current train. Perhaps relates to work in https://gerrit.wikimedia.org/r/q/topic:parser-toc so adding content transformers too)

None of my patches have been merged yet, so cannot be related to that. All of Scott's patches were from last year and they have been deployed for some time now. So, I don't think this is related to the work we are doing.

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

[mediawiki/skins/Vector@master] Fix mustache template rendering when TOC is rerendered after an edit

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

Test wiki created on Patch demo by BWang (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/ded90d2fbf/w

Change 878231 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Fix mustache template rendering when TOC is rerendered after an edit

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

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

[mediawiki/skins/Vector@wmf/1.40.0-wmf.17] Fix mustache template rendering when TOC is rerendered after an edit

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

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

[mediawiki/skins/Vector@wmf/1.40.0-wmf.18] Fix mustache template rendering when TOC is rerendered after an edit

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

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

[mediawiki/skins/Vector@master] Update tableOfContents.js to rerender only the TOC contents rather than the entire pinnable element

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

Change 879094 merged by jenkins-bot:

[mediawiki/skins/Vector@wmf/1.40.0-wmf.18] Fix mustache template rendering when TOC is rerendered after an edit

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

Mentioned in SAL (#wikimedia-operations) [2023-01-11T21:23:43Z] <kindrobot@deploy1002> Started scap: Backport for [[gerrit:879094|Fix mustache template rendering when TOC is rerendered after an edit (T326682)]], [[gerrit:879121|Enable page tools on beta cluster]]

Mentioned in SAL (#wikimedia-operations) [2023-01-11T21:25:27Z] <kindrobot@deploy1002> kindrobot and jdrewniak and jdlrobson: Backport for [[gerrit:879094|Fix mustache template rendering when TOC is rerendered after an edit (T326682)]], [[gerrit:879121|Enable page tools on beta cluster]] synced to the testservers: mwdebug2002.codfw.wmnet, mwdebug2001.codfw.wmnet, mwdebug1002.eqiad.wmnet, mwdebug1001.eqiad.wmnet

Mentioned in SAL (#wikimedia-operations) [2023-01-11T21:34:01Z] <kindrobot@deploy1002> Finished scap: Backport for [[gerrit:879094|Fix mustache template rendering when TOC is rerendered after an edit (T326682)]], [[gerrit:879121|Enable page tools on beta cluster]] (duration: 10m 17s)

Change 879093 abandoned by Bartosz Dziewoński:

[mediawiki/skins/Vector@wmf/1.40.0-wmf.17] Fix mustache template rendering when TOC is rerendered after an edit

Reason:

wmf.17 is not affected by the bug

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

(I believe this is no longer blocking wmf.18 deployment with this fix; it's just waiting for official approval from the team.)

Jdlrobson lowered the priority of this task from Unbreak Now! to High.Wed, Jan 11, 11:27 PM

This is no longer a deploy blocker but we have some follow up work to do before calling this done.

Test Result - Beta

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

Test Artifact(s):

QA Steps

✅ AC1: Verify Vector 2022 TOC is not undefined after making an edit using visual discussion tools

Screen Recording 2023-01-11 at 5.50.21 PM.mov.gif (1×1 px, 1 MB)

Screen Recording 2023-01-11 at 5.58.48 PM.mov.gif (1×1 px, 1 MB)

Edtadros added a subscriber: Edtadros.

Test Result - Prod

Status: ✅ PASS
Environment: testwiki
OS: macOS Ventura
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

✅ AC1: Verify Vector 2022 TOC is not undefined after making an edit using visual discussion tools

Screen Recording 2023-01-11 at 5.56.11 PM.mov.gif (1×1 px, 993 KB)

Screen Recording 2023-01-11 at 5.59.17 PM.mov.gif (1×1 px, 558 KB)