Background goal
Right now, ChipInput allows the user to add chips with whatever values they want, and doesn't suggest values. We should supporting adding a Menu below the input to suggest values, and support restricting the values that can be added to only those that appear in the menu.
Known use cases
ChipInput with menu in User's preferences. | |
T357710: Page titles selector control in Community Configuration. | |
T357708: Namespaces selector control in Community Configuration. | |
Commons/Wikiversity from T365532: Add Lookup component based on ChipInput to Codex. | |
Multiblock project | |
Design spec
Guidelines
Open questions
- What's the most straightforward way to enable configuration of the 3 different types of ChipInputs: only arbitrary content (no menu), only menu options, or menu options + arbitrary content? The OOUI MenuTagMultiselectWidget has an allowArbitrary property for this purpose, should we do something similar?
- Assuming we use a similar API to Lookup's (emit an input event and expect the parent component to update the menu-items prop), how do we make it easy for the parent component to not add a menu, without keeping the input in the pending state forever because we're waiting for menu-items to be updated?
- Perhaps this could be done by making menu-items optional, with a default value of null rather than [], to signify that no menu is used?
- What's the best way to de-duplicate logic between this new feature and the Lookup component? We can't use the Lookup component inside ChipInput because we can't achieve the single input UI with the existing TextInput, which must work without JavaScript. Should we copy over the Lookup code to ChipInput, or try to share it in a composable?
Acceptance criteria (or Done)
Design
- Design the Figma spec sheet and document its Guidelines T366006
- Update the component in the Figma library. This step will be done by a DST member.
- Update the ChipInput Guidelines including this new case
Code
- Implement the component's updates in Codex
- Demonstrate the 2 new types of ChipInputs: with menu and only allowing selection or menu items, or with menu but also allowing arbitrary user-submitted options