Page MenuHomePhabricator

Allow custom menu to be passed in to OO.ui.ButtonMenuSelectWidget
Closed, ResolvedPublic3 Estimated Story Points

Description

OO.ui.ButtonMenuSelectWidget currently constructs its own menu (an OO.ui.MenuSelectWidget) in its constructor: https://gerrit.wikimedia.org/g/oojs/ui/+/1d4e6ba5e8f0d541dd847059eef271da469ae082/src/widgets/ButtonMenuSelectWidget.js#62

Since T261862, Special:Investigate uses an OO.ui.ButtonMenuSelectWidget with a custom menu with custom event handlers.

We did this by subclassing OO.ui.ButtonMenuSelectWidget and adding our custom menu widget in the constructor of this subclass.

A less fragile long-term solution would be to allow a custom menu to be passed to OO.ui.ButtonMenuSelectWidget.

Acceptance Criteria
  • OO.ui.ButtonMenuSelectWidget adds a menu passed through the config. If none is passed, it behaves as before.

Event Timeline

Change 824296 had a related patch set uploaded (by AGueyte; author: AGueyte):

[mediawiki/extensions/CheckUser@master] WIP:Allow custom menu to be passed in to OO.ui.ButtonMenuSelectWidget

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

Change 824298 had a related patch set uploaded (by AGueyte; author: AGueyte):

[oojs/ui@master] WIP: Allow custom menu to be passed in to OO.ui.ButtonMenuSelectWidget

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

Change 825759 had a related patch set uploaded (by Tchanders; author: Tchanders):

[oojs/ui@master] Allow custom menu class to be passed in to OO.ui.ButtonMenuSelectWidget

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

Change 824298 abandoned by AGueyte:

[oojs/ui@master] WIP: Allow custom menu to be passed in to OO.ui.ButtonMenuSelectWidget

Reason:

Duplicate

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

Change 825759 merged by jenkins-bot:

[oojs/ui@master] Allow custom menu class to be passed in to OO.ui.ButtonMenuSelectWidget

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

dom_walden subscribed.

To test this change with the Special:Investigate tools menu, I copy and pasted the changes into resources/lib/ooui/oojs-ui-widgets.js and pulled the patch https://gerrit.wikimedia.org/r/c/mediawiki/extensions/CheckUser/+/824296 (as suggested here). I could use the tools menu with both keyboard and mouse and tabbing closes the menu (as it did before).

In case of regression, I tried to find a UI element using ButtonMenuSelectWidget but without passing a custom menu. CampaignEvents uses a dropdown menu on Special:MyEvents which inherits from ButtonMenuSelectWidget (see here). It worked with mouse and keyboard and pressing tab submits (as it did before).

Test environment: local docker CheckUser 2.5 (e72bc67) 15:41, 24 August 2022.

@Volker_E Is there a plan to make a new OOUI release?

Change 836237 had a related patch set uploaded (by Jforrester; author: Jforrester):

[mediawiki/core@master] Update OOUI to v0.45.0

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

Change 836237 merged by jenkins-bot:

[mediawiki/core@master] Update OOUI to v0.45.0

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