Steps to replicate the issue (include links if applicable):
- Enable the Vector 2022 skin on en.wiktionary.org
- Open https://en.wiktionary.org/wiki/house
- Refresh a couple of times
What happens?:
Sometimes the link "Citations" is added to the namespaces portlet (and looking wrong because of T345490):
Sometimes to the Tools portlet:
What should have happened instead?:
The link "Citations" should be added to the namespace tabs.
What is the cause of the issue:
A part of the reason is this piece of code in the Wiktionary gadget:
var portlet = document.getElementById('p-namespaces') ? 'p-namespaces' : 'p-cactions';
This code is there since 2014. It chooses the portlet (which then supplies to mw.util.addPortletLink) based on the presense of #p-namespaces on the page.
The second part of the reason is this piece of code added to resources/skins.vector.js/skin.js by @Jdlrobson as a temporary fix ("This code maps items added by gadgets to the new menu").
So, from the looks of it, this temporary fix doesn't work reliably for the case above and instead causes a race condition. Don't know what is the best solution here. (Is the check for document.getElementById('p-namespaces') existence even needed? Are we targeting some old skins with it?)