We now have two extensions (MachineVision and GrowthExperiments ) using a Suggestion Widget (see T237585 and T238610 for screenshots). It would be nice to consider upstreaming this so that both projects (and others in the future) can benefit from shared maintenance and development. At the moment we in Growth have copy-pasted (🙀) the code from MachineVision.
There are some issues with the existing code in MachineVision that I ran into when I copied it to GrowthExperiments:
- It depends on mediawiki.template.mustache+dom, which is in the WikibaseMediaInfo extension (MachineVision already depends on WBMI, but it doesn't make sense for GrowthExperiments to depend on WBMI)
- The mustache+dom templating engine avoids destructively rerendering embedded OOUI widgets, which is good, but it does destructively rerender nodes created by the template. This is a problem, because it breaks CSS transitions for state changes.
- Because CSS transitions don't work, the widget uses CSS animations instead. But that causes a bug where the widgets animate (the text moves from left to right) when they're being unhidden or added to the DOM.
- There is no clean group widget for these, so I had to make one by picking the relevant pieces from ImageWithSuggestionsWidget (which contains a lot of other things as well). Without that, the SuggestionWidgets don't behave correctly, because they rely on a CSS class set on the parent element to hide the outline.
- These widgets don't extend SelectWidget and OptionWidget, which means you have to reinvent some wheels around selection management and getting the selected values from the group widget for example
Overall I agree with @matmarex that this is functionally a CheckboxMultiselectWidget, just with different styling.