[go: up one dir, main page]

Page MenuHomePhabricator

TextArea: Add TextArea component to Codex
Closed, ResolvedPublic

Description

Background

Description

Multi-line text input that allows manual resizing

User stories

  • As a user, I need to enter a long text that exceeds one line (multiline).

History

Known as MultilineTextInputWidget in OOUI. Should use native <textarea> component and follow its attributes as much as possible.

Known use cases

Captura de Pantalla 2023-02-07 a las 20.05 1.png (703×1 px, 307 KB)
Captura de Pantalla 2023-02-07 a las 20.02 1.png (703×1 px, 398 KB)
VE publish dialog
growth-mobile.png (678×382 px, 83 KB)
image 6.png (445×939 px, 161 KB)
Text area use cases in Growth

Existing components

Wikimedia community:

External libraries:

Wikimedia Design Style Guide links:


Codex implementation

Component task owners

Open questions

  • Clearable action: it will not be included as we have in TextInput since it's not a common use case in text area and we would need extra padding. We will include it just if needed. (More info)
  • Character counter: helper text and character counter will be created as separated elements in the Field component. They won't be added in this Text area MVP task.
  • Text editing: it won't be implemented in this MVP task.

Design spec

Anatomy

The initial component will include the following properties:

Icons:

  • Text-only (no icon)
  • Start icon (customizable icon)
  • End icon (customizable icon)

Size:

  • Fixed-size (min-size 64px)
  • Grabber (customizable size)
  • Autosize (height will grow with the length of the text)
Style

The initial component will present the following visual features:

Interaction

The initial component will follow these interaction specifications:

  • Default
  • Hover
  • Active-Focus
  • Filled in
  • Disabled
  • Read-only
  • Error
  • Error focus (same focus style as in the Focus state)
  • Error filled
Documentation
  • Structure: Describe where the component will live in the sidebar hierarchy, e.g. a new sidebar item or within a group.
  • Content: Describe the content of the demo page. Aim to use a configurable demo for as many features as possible, then add standalone demos where needed.

Acceptance criteria

Minimum viable product

This task covers the minimum viable product (MVP) version of this component. MVP includes basic layout, default states, and most important functionality.

MVP scope

  • <textarea> element with styles matching the Figma spec sheet
  • Start and end icons
  • Prop for enabling autosize
  • All states documented in the spec sheet
  • RTL behavior documented in the spec sheet
  • All keyboard navigation documented in the spec sheet

Design

  • Design the Figma spec sheet and add a link to it in this task
  • Publish the component in the Figma library. This step will be done by a DST member.

Code

  • Implement the component in Codex

Future work

  • Enabling character count when used with the Field component

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes

Moving to the sprint so we can start working on it and solving any possible open questions before the end of February when the DST intern starts.

bmartinezcalvo added a subscriber: KieranMcCann.

I've prepared this Figma inventory and first component's exploration with some important use cases and needed component's properties. We need to detect the rest of relevant use cases in production but I think we can start with these ones.

Since this is a component migrated from OOUI we should maintain the same visual styles so both OOUI and Codex styles match (although we can propose some small visual changes if needed). Also we should keep the same states and colors as in TextInput.


@KieranMcCann assigning the task to you so you can check the visual style in case we need to improve something before starting with the spec sheet.

@bmartinezcalvo On the open question of 'clearable' element: I would not advise a clearable icon to Textarea. It's an element in all used in single line inputs and there specifically to my knowledge in nearly all cases only in search input fields.
As it's not common, it would be more confusing to users and it would open up issues like extra padding on the right over the full vertical length leading to imbalanced layout.

How do we feel about including a character count, either a pure count (e.g. 52), a limit (e.g. 100), or a dynamic status (e.g. 52/100)? I see this in one of the Growth team's use cases, and think it would be a helpful feature to include.

That seems like a necessity to me, see VE's edit summary dialog

image.png (348×964 px, 35 KB)
(visible when <=100 chars left)

Probably not for the MVP though…?!

I agree that it doesn't need to be included for MVP. It might be a fun subsequent task to work on for our intern, though, if we get to it.

How do we feel about including a character count, either a pure count (e.g. 52), a limit (e.g. 100), or a dynamic status (e.g. 52/100)? I see this in one of the Growth team's use cases, and think it would be a helpful feature to include.

@AnneT I would move the character counter to the helper text section in order to avoid the character counter being mixed with the text area content when the text is long.

Captura de Pantalla 2023-02-08 a las 17.40.10.png (486×820 px, 164 KB)
Captura de Pantalla 2023-02-08 a las 17.40.22.png (512×816 px, 174 KB)
Characters counter in the helper text sectionCharacters counter within the text area

@bmartinezcalvo Exactly, the extra padding on within the text area is ending up imbalanced and looses valuable space for user input. It also aligns with the VE edit summary dialog.

@bmartinezcalvo makes sense!

Question about the helper text: is this specific to the Textarea component, or will it be a standard part of most form elements? I'm trying to figure out if that would go in the Textarea component itself, or in a generic Field component that contains a Label, form element, inline validation message, and helper text

Looks good to me @bmartinezcalvo.

Regarding the counter I agree with having it outside the field in the helper text section and right aligned.

In the documentation should we provide guidelines for how tall the input should be as default, and for how it should be adapted in designs? It is usually good practice to make the height of a textarea proportional to the amount of text you expect users to enter – so they have a rough idea of what is expected of them.

Question about the helper text: is this specific to the Textarea component, or will it be a standard part of most form elements? I'm trying to figure out if that would go in the Textarea component itself, or in a generic Field component that contains a Label, form element, inline validation message, and helper text

@AnneT helper text is a text that provides the user about relevant info to include in the field. It's an element that should be added in Textarea but also in some other form items such as TextInput. So I would create Helper text if possible as a separate component. At the moment I think we are using InlineMessage for feedback messages below the Inputs, but I think helper text it's a different element.

So yes, I think any form item should include:

  • Label
  • Field (Textarea, TextInput, etc.)
  • Helper text (if needed) to provide important info to add in the field (e.g. "use just numeric characters") and that could have also a character counter on the right for the text area.
  • Inline message (if needed) to provide feedback to the user (e.g. the error message)

Looks good to me @bmartinezcalvo.

Regarding the counter I agree with having it outside the field in the helper text section and right aligned.

In the documentation should we provide guidelines for how tall the input should be as default, and for how it should be adapted in designs? It is usually good practice to make the height of a textarea proportional to the amount of text you expect users to enter – so they have a rough idea of what is expected of them.

@KieranMcCann I've detected the following sizes use cases that will be included in the final spec sheet:

Captura de Pantalla 2023-02-09 a las 16.52.16.png (884×2 px, 730 KB)

  • Min size: we could use 64px or 128px. I lean towards 64px as min-size since the user will sometimes not need to add more than 2 text lines. But let me know your thoughts.
  • Apart from the min sizes, we could improve the following props:
    • Grab: when grabbing, the user could resize the component's width and height.
    • Scroll: a scroll could appear when the text area height is fixed.
    • Autosize: text area could grow with the length of the text automatically.

The HTML <textarea> component has an attribute called row that is the number of visible lines of text, determining the height of the element. I'd recommend we allow users to bind the row attribute to the CdxTextarea component, which will then apply it to the <textarea> element within.

For the 3 other props you mentioned (grab, scroll, and autosize), I think we will just need a single prop: autosize. If set to false, the grabber will be present, and scroll will appear if the text is longer than the visible window. If autosize is set to true, the grabber will not be present, and scroll will not appear because the element will keep growing as more text is added.

This is how the OOUI MultilineTextInputWidget works.

We'll also want to think about the horizontal width...<textarea> also has an attribute for columns to set the initial width, but we might want to default to 100% width, right?

Agreed on using row. A min-height (and if so the smaller one of 64px) could still be useful to more clearly visually differentiate to a single-line TextInput.
columns on the other hand often seems like black magic (what is a column's width?). I'd refer to full-size context-specific.

bmartinezcalvo added a subscriber: RHo.

I've created the first iteration for the Text area component's spec sheet applying the solved open questions listed in the task:

  • Clearable action will not be included in the text area
  • Character counter will be included as part of the Field component T309239
  • Text editing won't be implemented in this MVP task, so text format will not be customizable

@KieranMcCann assigning you the task so you can double check that the visual styles we commented have been applied. @RHo for generic feedback.

@RHo let us also know your feedback on the design spec before sending the task to Ready for Development.

AnneT renamed this task from Design and build initial Textarea (multiline input) component (MVP) to TextArea: Add TextArea component to Codex.Feb 21 2023, 8:10 PM
AnneT updated the task description. (Show Details)

Moving the task to Ready for Development to avoid blocking this task. We can move the task to In Design in the future if more feedback is provided about the spec.

Sorry I'm late, but per @AnneT and @Volker_E's earlier comments, could we add character count as a follow up task to MVP? There was some old explorations that recall being made when multilingual captions were being worked on for the Structured Data on Commons project which accounted for difference use-cases that would be useful to include:

  • Minimum character limit - this is in use on Growth's Add image task as well as Commons captions
    image.png (350×1 px, 42 KB)
  • Max character limit - this could be expressed as incrementing to a total char count, or else countdown to being over, and possibly even highlighting extra characters like twitter does
    image.png (690×1 px, 161 KB)
  • Word count min/max limits - this might be out of scope for char count follow up but in the case of captions, min. word count is what would have been preferred for more languages.

Sorry I'm late, but per @AnneT and @Volker_E's earlier comments, could we add character count as a follow up task to MVP?

@RHo I guess characters count will be implemented as part of Field component in T309239.

Sorry I'm late, but per @AnneT and @Volker_E's earlier comments, could we add character count as a follow up task to MVP?

@RHo I guess characters count will be implemented as part of Field component in T309239.

Thanks! Re-posting to the right task.

The TextArea design spec expects the grabber /resize tool to have 4x padding.

Captura de pantalla 2023-06-06 a las 19.32.20.png (676×840 px, 20 KB)

I haven't been able to find a simple solution to adding the padding to the grabber. One solution is creating a custom grabber tool that we can target and apply the styles needed. We'd also have to ensure the custom grabber is properly aligned when textarea height grows.

@bmartinezcalvo and I agreed on removing this from the design spec since it was a low priority.

I'm open to discussion with the team.

+1 to this decision, it would be hard/impossible to get a custom grabber consistent across browsers, so using the browser-provided one seems like the safer route

The TextArea design spec expects the grabber /resize tool to have 4x padding.

Captura de pantalla 2023-06-06 a las 19.32.20.png (676×840 px, 20 KB)

I haven't been able to find a simple solution to adding the padding to the grabber. One solution is creating a custom grabber tool that we can target and apply the styles needed. We'd also have to ensure the custom grabber is properly aligned when textarea height grows.

@bmartinezcalvo and I agreed on removing this from the design spec since it was a low priority.

I'm open to discussion with the team.

@lwatson updated the Figma exploration file and the Figma library with this decision.

This comment was removed by lwatson.
lwatson claimed this task.
lwatson updated the task description. (Show Details)