-
Notifications
You must be signed in to change notification settings - Fork 447
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
Required fields in form are still required even if field/group is hidden #9996
Comments
@ewhanson This should resolve the workaround you are having in OrcidForm.vue. What you think? ui-library: pkp/ui-library#357 |
Hey @jardakotesovec, thanks for this! I think this gets most of the way to solving my issues. It is possible to save a form with conditionally hidden required elements blank, but if there are previous errors, they are not dismissed when the fields are hidden (see video). orcid_settings.mp4 |
@ewhanson Ok.. additionally added removing error on field unmount, which can be think about as clean up for field which is not relevant anymore. At this point I think this should work well.. can't think of where it could cause problems at this point.. but if you can think of something please let me know! |
Thanks @jardakotesovec! This is most of the way there now, but I'm still running into an error. It seems that only one error is removed at a time when the components are unmounted. I have an example where there are 3 "required fields not completed" errors. And each time I hide/unmount the components, another one of the errors is removed. orcid.mp4 |
@ewhanson Great catch, thanks! I did not test it with more than one field, so I did not notice it. It went wrong, because how the state management is structured currently there. So every removing error created new errors object with that one error removed. But the errors object prop don't get propagated between these calls.. so all of them were modifying the original object and basically last change win. Not fan of the solution I end up with.. hence the long comment in the code.. but it does work and I still think that this is how it should behave and it should remove the errors if the field gets removed. |
Hey @jardakotesovec, that makes sense. I've done some testing with the latest changes and it's working as expected now. 👍 |
#357) * pkp/pkp-lib#9996 Remove error for input that gets hidden * pkp/pkp-lib#9996 check only visible fields for required * pkp/pkp-lib#9996 Handle correctly multiple fields removing error synchronously * pkp/pkp-lib#9996 add jsdocs
@ewhanson Thank you, merged. |
Describe the bug
Orcid form has use case, where first field enables Orcid and as result display rest of the form and some of the fields there are required. Problem is during validation, because the validation does not take in account if some fields are hidden.
Proposed solution
I think that improving form behaviour so it skips required fields if they are conditionally hidden would be expected behaviour.
What application are you using?
OJS, OMP or OPS version main
The text was updated successfully, but these errors were encountered: