fix: send an event-like object into Field onChange when no event (#4548) #4604
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The docs mention that it is possible for an input to call
input.onChange
and pass either an event or a new value as the argument.They also mention that it's possible to pass
onChange
to a<Field />
component, and that handler should receive an event as its first argument, with apreventDefault
method on it which will prevent the change from being dispatched.It's not explained in the docs that there's any connection between these two APIs. However, since this change, the consumer only receives an event object in
Field.onChange
if the underlying input has calledinput.onChange
with an event.Since many people (including myself) have been relying on the ability to BOTH pass a value to
input.onChange
and callevent.preventDefault()
within theField.onChange
handler, I think we should either make that possible or update the docs to explain the restriction. This PR makes it possible.Closes #4548