-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix custom input's onChange handlers should have access to updated context value #8903
Conversation
Hi! Thanks for submitting this! 🙂 However, I'm not sure I understand, though. You can still access the newer value of the input via |
The benefit is to grab all the values of the form at once to give them to a process, including the one that just has been changed, without having to differentiate that one by grab it from another place. |
I see. Thanks for the clarifications. 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that this is a welcome change, however I'd prefer that you PR against next
. As it may break things in corner cases, we need to prevent that from happening in a bug fix release.
Also, the order change was introduced by @djhi in 9dfaf4e. I wonder it you have any recollection of why you didi so?
I'm updating a project from ra-v3 to ra-v4 where the value of change inputs is taken from the Form state within the onChange / onBlur event handler (instead of its
e.target.value
argument), and it doesn't have the updated value.I found out that :
In react-admin v3 inputs run custom event handlers after react-final-form ones.
In react-admin v4 inputs run custom event handlers before react-hook-form ones.
So, changing this order of execution to match ra-v3 allows
useFormContext().getValues()
to have the latest value inside the custom event handlers.