Page MenuHomePhabricator

[Gadget support] Add parameter to mw.util.addPortlet() to append portlet directly to DOM
Closed, ResolvedPublicBUG REPORT

Description

Currently mw.util.addPortlet() when used by gadgets creates an undetached portlet element. Since mw.util.addPortletLink() does not work on detached nodes, the DOM node must be appended beforehand.

Having knowledge of where the element is in the DOM would help in the implementation of T342815 as it would allow skins which have different types of menu to deduce what type the new menu should be.

TODO

  • A second parameter is proposed that states a preferred location for the new menu e.g. mw.util.addPortlet( 'p-twinkle', 'Twinkle', '#p-cactions' )
  • The parameter results in the element being appended in the DOM.
  • The selector should be passed to the existing util.addPortlet hook so skins can use it to determine type.
  • If a selector is passed the method should return null rather than the detached DOM node to avoid unexpected side effects from caller trying to add it somewhere else directly afterwards.

Event Timeline

matmarex renamed this task from [Gadget support] Add parameter to mw.util.addPortlet link to append portlet directly to DOM to [Gadget support] Add parameter to mw.util.addPortlet() to append portlet directly to DOM.Sep 5 2023, 7:54 PM
matmarex updated the task description. (Show Details)
Jdlrobson raised the priority of this task from Medium to High.Sep 11 2023, 5:53 PM

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

[mediawiki/core@master] [Gadget support] Add parameter to mw.util.addPortlet() to append portlet directly to DOM

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

Change 958576 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.util: Allow mw.util.addPortlet() to attach new portlet to DOM

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

Jdlrobson claimed this task.

@Novem_Linguae @MusikAnimal this will ride next week's train. I will prioritize the dropdown API to follow shortly T342815. Please let me know if you need any help with updating your scripts (e.g. https://en.wikipedia.org/wiki/User:Novem%20Linguae/Scripts/NPPLinks.js)