-
Notifications
You must be signed in to change notification settings - Fork 167
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
Binder.setAsRequiredEnabled instantly validates the field #17515
Comments
caalador
moved this to 🔖 Normal Priority (P2)
in Vaadin Flow bugs & maintenance (Vaadin 10+)
Sep 20, 2023
mshabarov
moved this to 🅿️Parking lot - under consideration
in Vaadin Flow ongoing work (Vaadin 10+)
Sep 28, 2023
This was referenced Jan 24, 2024
Closed
Closed
Merged
github-project-automation
bot
moved this from 🔖 Normal Priority (P2)
to ✅ Closed
in Vaadin Flow bugs & maintenance (Vaadin 10+)
Jan 26, 2024
vaadin-bot
pushed a commit
that referenced
this issue
Jan 26, 2024
Changes: - Once Binder.handleFieldValueChange runs for a binding when readBean was used, the whole binder will be silently validated also. BinderValidationStatusHandler is called like before (only contains status from changed binding), but StatusChangeEvent is now fired considering all bindings and if possible bean validators as well. - Once Binder.handleFieldValueChange runs for a binding when setBean was used, doWriteIfValid will validate all bindings, not only the changed ones. This prevents writing an invalid bean in cases where one or more of the initial values are in invalid state (but not marked as such since setBean resets validation status), but they have not been changed from their initial value(s). Calling setAsRequiredEnabled with a changed value no longer triggers validation, since that validation is now handled elsewhere when needed as stated above. Minor Javadoc fixes, trying to align Javadocs with code. Fixes #18163 Fixes #4988 Fixes #17515
vaadin-bot
pushed a commit
that referenced
this issue
Jan 26, 2024
Changes: - Once Binder.handleFieldValueChange runs for a binding when readBean was used, the whole binder will be silently validated also. BinderValidationStatusHandler is called like before (only contains status from changed binding), but StatusChangeEvent is now fired considering all bindings and if possible bean validators as well. - Once Binder.handleFieldValueChange runs for a binding when setBean was used, doWriteIfValid will validate all bindings, not only the changed ones. This prevents writing an invalid bean in cases where one or more of the initial values are in invalid state (but not marked as such since setBean resets validation status), but they have not been changed from their initial value(s). Calling setAsRequiredEnabled with a changed value no longer triggers validation, since that validation is now handled elsewhere when needed as stated above. Minor Javadoc fixes, trying to align Javadocs with code. Fixes #18163 Fixes #4988 Fixes #17515
vaadin-bot
added a commit
that referenced
this issue
Jan 26, 2024
Changes: - Once Binder.handleFieldValueChange runs for a binding when readBean was used, the whole binder will be silently validated also. BinderValidationStatusHandler is called like before (only contains status from changed binding), but StatusChangeEvent is now fired considering all bindings and if possible bean validators as well. - Once Binder.handleFieldValueChange runs for a binding when setBean was used, doWriteIfValid will validate all bindings, not only the changed ones. This prevents writing an invalid bean in cases where one or more of the initial values are in invalid state (but not marked as such since setBean resets validation status), but they have not been changed from their initial value(s). Calling setAsRequiredEnabled with a changed value no longer triggers validation, since that validation is now handled elsewhere when needed as stated above. Minor Javadoc fixes, trying to align Javadocs with code. Fixes #18163 Fixes #4988 Fixes #17515 Co-authored-by: Teppo Kurki <[email protected]>
vaadin-bot
added a commit
that referenced
this issue
Jan 26, 2024
Changes: - Once Binder.handleFieldValueChange runs for a binding when readBean was used, the whole binder will be silently validated also. BinderValidationStatusHandler is called like before (only contains status from changed binding), but StatusChangeEvent is now fired considering all bindings and if possible bean validators as well. - Once Binder.handleFieldValueChange runs for a binding when setBean was used, doWriteIfValid will validate all bindings, not only the changed ones. This prevents writing an invalid bean in cases where one or more of the initial values are in invalid state (but not marked as such since setBean resets validation status), but they have not been changed from their initial value(s). Calling setAsRequiredEnabled with a changed value no longer triggers validation, since that validation is now handled elsewhere when needed as stated above. Minor Javadoc fixes, trying to align Javadocs with code. Fixes #18163 Fixes #4988 Fixes #17515 Co-authored-by: Teppo Kurki <[email protected]>
This ticket/PR has been released with Vaadin 24.3.4. |
github-project-automation
bot
moved this to Closed
in OLD Vaadin Flow bugs & maintenance (Vaadin 10+)
Aug 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description of the bug
Using setAsRequiredEnabled instantly validates the bound field. As this leads to a pretty bad UX/UI this is a bug for me.
I have a checkbox. When the checkbox is checked, a text field is visible, which in this case is required. When the checkbox is unchecked, the text field is no longer required, so the asRequired state must be changed. Otherwise the form will be invalid on a hidden text field. I'm using setAsRequiredEnabled, which means that when the checkbox is checked, the text field is immediately invalid and red.
As the user hasn't even had a chance to enter anything, this is bad UX. I don't see why the validation has to be immediate.
Workaround:
Adding and removing the whole binder.
Expected behavior
Validation is not performed immediately.
Minimal reproducible example
I won't provide an reproducible example here as you can see it directly in the source code:
flow/flow-data/src/main/java/com/vaadin/flow/data/binder/Binder.java
Lines 1530 to 1541 in 49d68c7
Versions
Vaadin: 24.1.2
Flow: 24.1.3
Java: Amazon.com Inc. 17.0.8.1
OS: amd64 Linux 6.2.0-26-generic
Browser: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36
Live reload: Java active (Spring Boot Devtools): Front end active
The text was updated successfully, but these errors were encountered: