Page MenuHomePhabricator

TextInput: Emit a "clear" event when the clear button is clicked
Closed, ResolvedPublic1 Estimated Story Points

Description

In the process of migrating MediaSearch to Codex (see T336821) (, I've found a couple of behaviors that the existing sd-components possess which their Codex equivalents lack.

One example is having a dedicated clear event that is emitted by the text input component when a user clicks the optional clear button to remove all text at once.

In MediaSearch, this event is treated differently from a simple text change – the clear event is used as a signal to discard all previous search results (otherwise, search results from the previous query persist while the user makes single-letter changes in the input, and a new search is only performed when they select a lookup result or click on the search button).

It's not unreasonable to think that other features may need to assign special behavior to the use of the clear button as well.

Proposal

Let's add a clear event to the CdxTextInput component which is fired when the clear button is clicked. This event probably doesn't need a payload, and users can safely ignore it if they don't care about this behavior.

Event Timeline

Restricted Application triaged this task as High priority. · View Herald TranscriptMay 18 2023, 4:54 PM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
egardner set the point value for this task to 1.May 18 2023, 4:54 PM
egardner updated the task description. (Show Details)

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

[design/codex@main] TextInput: Emit a "clear" event when clear button is clicked

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

Change 921074 merged by jenkins-bot:

[design/codex@main] TextInput: Emit a "clear" event when clear button is clicked

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

Change 922610 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/core@master] Update Codex from v0.10.0 to v0.11.0

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

Change 922610 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v0.10.0 to v0.11.0

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

egardner renamed this task from TextArea: Emit a "clear" event when the clear button is clicked to TextInput: Emit a "clear" event when the clear button is clicked.May 25 2023, 4:49 AM