Skip to content

Add event that behaves similar to the native change event #4126

Closed
@dantman

Description

@dantman

Because React has repurposed onChange to behave like onInput there is no way to get actual change event behaviour without binding a non-delegated native event in lifecycle events.

change event behaviour is sometimes important to have. input-like behaviour does make sense for what React uses onChange for (live updating of state associated with value="" and anything derived from it). But other use cases, like triggering an ajax post once a user has finished with an input, require the standard behaviour of change for text inputs where it is only fired after a user is finished with the input.

These use cases are reasonable to support within React. If onChange is going to be changed to behave in a non-standard way. Then we should add another custom non-standard event name that lets React elements bind to behaviour that is closer to how change behaves (with React's event delegation handling).

Event name ideas:

  • onChangeCommit(ted)
  • onCommit(ted)Change
  • onValueCommit(ted)
  • onCommitValue
  • onCommit?

The idea of using "commit" in the name comes from the HTML spec.

The change event fires when the value is committed, [...]

~ Section 4.10.5.5 Common event behaviours

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions