Page MenuHomePhabricator

Last item in personal menu has two icons when in debug mode
Closed, ResolvedPublic

Description

  1. Login
  2. View a page with ResourceLoader debugging enabled: https://en.wikipedia.org/wiki/Main_Page?useskin=vector-2022&debug=1

Observe the last menu item has two icons:

image.png (320×224 px, 14 KB)

Event Timeline

@Jdlrobson CX is using mw.util.addPortletLink - Infact you made that change a few months ago.
In debug mode alone, I see that addPortletLinkHandler in skins.vector.js/dropdownMenus.js is getting called two times.

I suspect the following code is problematic:

// Enhance previously added items.
Array.prototype.forEach.call(
	document.querySelectorAll( '.mw-list-item-js' ),
	function ( item ) {
		addPortletLinkHandler( item, {
			id: item.getAttribute( 'id' )
		} );
	}
);

mw.hook( 'util.addPortletLink' ).add( addPortletLinkHandler );

There is a chance that addPortletLinkHandler called more than once for same item and id depending on whether document.querySelectorAll( '.mw-list-item-js' ) returns the item which already fired the 'util.addPortletLink' hook event. addPortletLinkHandler adds two icons in that case.

@Jdlrobson CX is using mw.util.addPortletLink - Infact you made that change a few months ago.

Right. I stand corrected (The use of jQuery threw me).
The addPortletLinkHandler should only be called once on each item added.

Change 836254 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] Fixes to addPortletLink hook handler

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

Change 836254 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Fixes to addPortletLink hook handler

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