removing content from text field result in empty string instead of undefined#539
removing content from text field result in empty string instead of undefined#539n1k0 merged 3 commits intorjsf-team:masterfrom quentin-sommer:master
Conversation
|
I'm not sure we want to revert the old behavior. We spent weeks (months) aligning on this and it was hard to reach consensus. Please ensure reading comments in related issues, there are a lot of constraints which may not be obvious at first glance. Could you please describe a little more your specific use case so we can ensure we're not missing any piece of valuable information here? Calling @crumblix @olzraiti @revolunet @ @Reggino @knilink @vinhlh @mplis-jetsetter @glasserc @MoOx and other people interested in this project to provide feedback. |
|
Hi, When implementing data edit forms and dealing with strings I think we have 2 use cases
One way to make is this is to leverage the The behavior I'd like to see is the following:
|
|
I agree that there are two different, valid use cases for an empty string field. I've come across both since I started using this library. I like giving the user some control to define the behavior.
|
|
I agree with @quentin-sommer the current string-array handling feels weird and needs some attention :-) I agree with @MPLIS it would simply be annoying whenever you would try to clear an input and it is instantly reset to some default value. Can't we just add a new option to the uischema? Something like |
|
I've implemented the change on the pull request so you can try it out here the |
|
This is really good, and it solves all the constraints I had in mind. Could you please add some documentation in the README so we can land this patch? Edit: you've added docs I've missed for some reason. I'm landing this! |
|
Released in v0.46.0. |
Reasons for making this change
As mentioned here before #476 (comment)
The new way of handling empty text fields (setting them to undefined) is undesirable as most of the time we want to keep an empty value.
If we want to delete a field we can do so after the form validation by for emptiness and delete accordingly.
Behavior change:
""instead of undefined when you remove everything inside itChecklist
npm run cs-formaton my branch to conform my code to prettier coding stylePlease take in consideration that I'm fairly new to the repo and might have underestimated the change, I'd like your input if that's the case!
Quentin