Page MenuHomePhabricator

TextArea: pass most attributes down to the <textarea> element
Closed, ResolvedPublic

Description

In addition to props, developers can bind attributes to Vue components when using them, like so:

<cdx-text-input placeholder="Search" />

By default, all attributes will be applied to the root element of the component. Sometimes, though, this is not what we want. In the example above, we actually want the placeholder to be applied to the <input> element within the TextArea component, not to the outer <div> element. In order to actually work as a placeholder attribute, it must be bound to the <input>.

However, there are 2 attributes that should always be bound to the root element: class and style. When a developer adds a custom CSS class to a Vue component, for example, they probably want that class on the outer-most element so they can apply styles to the entire component and any of its sub-elements.

To resolve this common issue, we have created a composable in Codex called useSplitAttributes. See the Codex contributing docs for more info.


Acceptance criteria

  • useSplitAttributes is implemented in the CdxTextArea component
  • A new snapshot test is added to demonstrate this behavior (see TextInput.test.ts for an example)
  • A placeholder attribute is added to the TextAreaDemo component to show that this works as expected

Event Timeline

AnneT updated the task description. (Show Details)

Change 904607 had a related patch set uploaded (by LWatson; author: LWatson):

[design/codex@main] TextArea: pass most attributes down to the <textarea> element

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

Change 904607 merged by jenkins-bot:

[design/codex@main] TextArea: pass most attributes down to the <textarea> element

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

AnneT updated the task description. (Show Details)

Change 907988 had a related patch set uploaded (by Eric Gardner; author: Eric Gardner):

[mediawiki/core@master] Update Codex from v0.8.0 to v0.9.0

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

Change 907988 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v0.8.0 to v0.9.0

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

Test wiki created on Patch demo by KHarlan (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/cfdfa13682/w

Test wiki on Patch demo by KHarlan (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/cfdfa13682/w/