Closed inspiring71 closed 4 weeks ago
Hi @inspiring71, the form refreshes its state because it rerenders when you call setErrors()
in blurHandler
and the formData
is not passed as a prop, that's why you lose that state. The formData
needs to be passed as a prop so that when you rerender the form doesn't think you have cleared the formData
. I have changed the code in your example to make it work, click here to see it.
Thanks @abdalla-rko , both for the tip and the attached sandbox. As you know your ways around this library better than me, I was wondering if there is any straightforward way to get the field path of an input when onBlur event is called?
I found a hack that works fine for now, but it seems like finding the field path of the element that invoked the event should be more straight forward. Any idea?
Thanks @abdalla-rko , both for the tip and the attached sandbox. As you know your ways around this library better than me, I was wondering if there is any straightforward way to get the field path of an input when onBlur event is called?
I found a hack that works fine for now, but it seems like finding the field path of the element that invoked the event should be more straight forward. Any idea?
@inspiring71 you can use the idSeparator prop on the form to change to use a .
and then you can split on .
to get the field path array that you can use in lodash
.
Also, all of the onBlur()
callbacks should be passing in the field id as the first parameter.
Thanks for the response @heath-freenome . I will try idSeparator
and I think it would simplify what I am doing drastically. I will close this issue now.
Prerequisites
What theme are you using?
core
Version
5.x
Current Behavior
When the extraError prop is passed to the Form component, any updates to extraError cause the library to remove all dynamically added array fields and refresh the UI components unexpectedly.
https://github.com/user-attachments/assets/09ded61c-f741-4714-bd82-15c2c786af95
You can find the check the example code here: https://codesandbox.io/p/devbox/2gvwxk
Expected Behavior
I expect the fields to remain on the page and not disappear.
Steps To Reproduce
extraError
prop to the Form component.Environment
Anything else?
I was trying to implement this feature when face with this error: https://github.com/rjsf-team/react-jsonschema-form/issues/617#issuecomment-1003141946
Also, Let me thank you for all the hard works, I know it is not easy to be an OSS developer.
BTW, I am willing to fix the issue myself but as I am new to this repo, needs some pointers on where this problem is originated.