Background
A common use case across products is a checkbox or radio that, when checked, displays a text input or text area to capture further user input. This is included in our form guidelines:
Given the prevalence of this use case, and that we want to standardize its design, we should build this into the Checkbox and Radio components. Note that we may want this for other components in the future as well (e.g. for "select or other" fields, something that exists in HTMLForm and is being used on Special:Block).
Known use cases
Trust & Safety Product Team (Figma). | |
Others:
- In Adiutor, there's a checkbox that shows a text input field when checked. I will note that it's not styled according to our designs (see screenshot)
- In ReportIncident, there's a checkbox that shows a text area when checked. I don't have this installed locally and am unsure of whether it's in production anywhere, but hopefully the code can help
Design spec
Link it here once it's completed.
Checkbox spec sheet | Radio spec sheet |
Guidelines
Link it here once it's completed.
Google doc with the Guidelines |
Implementation
We will want to add a few new props to Checkbox and Radio (prop names are open for debate)
- showOther: a boolean prop that, when true, will add a TextInput or TextArea
- otherComponent: a prop that can either be 'text' or 'textarea', defaulting to 'text' (the name of these strings is also up for debate. This could also be a boolean prop like useTextArea or something)
- otherValue: the value of that input, bound with v-model:otherValue
The Checkbox and Radio templates will need to be updated to conditionally show the TextInput or TextArea, and appropriate styles will be added.
Finally, we'll need tests and demos.
Acceptance criteria
Design
- Design the Figma spec sheet and include its link in this task:
- Include a list of keyboard shortcuts to navigate the component (if needed)
- Provide Guidelines for the new properties of Checkbox and Radio
- Update the main component in the Figma library. This step will be done by a DST member.
Code
- A TextInput or TextArea can be conditionally added below a Checkbox or Radio
- The TextInput or TextArea is styled in line with the Figma designs
- The new functionality is covered by unit tests
- A new demo is added to each component's demo page showing the new functionality