Skip to content

[TextField] Enable differentiating between typed changes and step control changes for number inputs #8760

@stefanlegg

Description

@stefanlegg

Feature request summary

There are instances where we can provide better UX if we're able to differentiate between a user typing a new value and clicking the stepper control to change the value. For example, Lets say you provided a step value of 5 and your intention is to keep the field value at multiples of 5. With the behavior today if the current typed value is 1, and they step upwards they'll go to 6, and there is no reasonable way to "autocorrect".

This may be easily achievable via a second option onStepperChange callback that would be called instead of onChange, if provided, within handleNumberChange

More context on the need for this can be found in this epic.

Rationale

  • Allows different handling if the user typed a value vs changed using the step control
  • Why is onChange alone insufficient?
    • Autocorrecting during typed onChange events would provide an unwanted experience. Consider the case where step is 5 and the user is trying to type 25. If you autocorrect during onChange you would correct them to 5 after they press 2, and then the subsequent typed 0 will take them to 50.

🌟 Feature requests that are not yet planned will be closed. We then use the issue’s 👍 upvotes to track and set priorities. See the contribution guidelines for more information.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions