Page MenuHomePhabricator

Add TextInput component to Codex
Closed, ResolvedPublic

Description

Existing components

Wikimedia community:

External libraries:

Wikimedia Design Style Guide links:

Implementation notes

Scope

An Input component can have various features, and we should decide which should be included in the Input component itself and which should be added in a future Field component.

Potential features:

  • Configurable icon
  • Clearable (with configurable icon)
  • Label
  • Validation (visual change on error, error message)

Existing implementations:

  • WVUI: Input has configurable icon, clearable (with configurable icon)
  • WiKit: Input has none of these features, TextInput has label and validation
  • CX: MWInput has configurable icon, configurable indicator that just emits an event when clicked
Input type

Should Input support only text, text and search, or more?

Existing implementations:

  • WVUI: Input type prop must be of type InputType, which can be search or text
  • WiKit: Input (and, subsequently, TextInput) is always type text
  • CX: MWInput has type prop which can be input, search, or textarea (via prop validation). Type textarea will result in a <textarea> element instead of <input>

Should it include textarea, or should that be a separate component? Handled in T284272

Misc.

Some notes on other features we probably want to cover:

  • Placeholder text is described in the DSG and there should be a mechanism for setting it
  • The WVUI Input sets v-bind="$attrs" on the <input> element, which enables the end user to set attributes like dir, autocapitalize, and autocomplete on the <wvui-input> component, which will then be passed to its <input> element
  • The WVUI Input emits events on change, focus, and blur in case the parent component wants to know about those things

Event Timeline

I'd like to hear from some folks who have been around for more OOUI history, but I think it makes sense to:

  • Build an Input component that can be type text or search, with a configurable icon and a configurable indicator icon that will clear the input on click
  • Build a separate Textarea component (since, according to the DSG, textareas can't have icons or indicators)
  • Build a separate Field component that:
    • Takes in some kind of input(s) (Input, Textarea, a group of Radios or Checkboxes, etc.) via its default slot
    • Includes a label
    • Includes validation messages, and passes a validation prop to its children so they can be styled differently on warning/error

I'd like to hear from some folks who have been around for more OOUI history, but I think it makes sense to:

This seems all reasonable to me with one small refinement:

  • Build an Input component that can be type text or search, with a configurable icon and a configurable indicator icon that will clear the input on click
  • Build a separate Textarea component (since, according to the DSG, textareas can't have icons or indicators)

They are supposed to have icons and indicators too. Indicators as it's our current way of signifying that a textarea is required to be not empty when submitting a form. And icons for general styling abilities. DSG could be clearer about this.

Change 735442 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):

[design/codex@main] TextInput: Add the TextInput component

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

Change 735442 merged by jenkins-bot:

[design/codex@main] TextInput: Add the TextInput component

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

AnneT renamed this task from Add Input component to Codex to Add TextInput component to Codex.Nov 18 2021, 5:27 PM
Volker_E updated the task description. (Show Details)

The open connected topics here are further handled in their own tasks

TextInput has been added before and with the initial Codex release v0.1.0-alpha.1 / 2022-02-14. Resolving successfully.