Skip to content
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

Vaadin Flow 24.4.0.alpha4 validation process #18735

Closed
alexanoid opened this issue Feb 17, 2024 · 5 comments · Fixed by #18760
Closed

Vaadin Flow 24.4.0.alpha4 validation process #18735

alexanoid opened this issue Feb 17, 2024 · 5 comments · Fixed by #18760
Assignees

Comments

@alexanoid
Copy link

alexanoid commented Feb 17, 2024

Description of the bug

  1. With 24.4.0.alpha4, something changed in the form validation process. Once I enter the first value, it immediately highlights the entire form with validation errors on the mandatory fields:

form

Previously, in version 24.4.0.alpha2, the validation started working only after I pressed the Save button. How can I control this behavior in version 24.4.0.alpha4?

Expected behavior

Validation should not highlight fields until the Save button is clicked.

Minimal reproducible example

n/a

Versions

  • Vaadin / Flow version: 24.4.0.alpha4
@mcollovati
Copy link
Collaborator

Thanks for reporting. Could you please create a separated ticket for the drawer issue? It would be simpler to track

@alexanoid alexanoid changed the title Vaadin Flow 24.4.0.alpha4 validation process, RouterLink in Drawer Vaadin Flow 24.4.0.alpha4 validation process Feb 17, 2024
@alexanoid
Copy link
Author

sure, done #18736

@mcollovati
Copy link
Collaborator

mcollovati commented Feb 19, 2024

@alexanoid could you please share the Binder configuration code?
I tried to reproduce with binder.forField(...).asRequired("You must fill this").bind(.....) but the validation is only triggered on the edited field.

EDIT: never mind. I can reproduce the issue by calling Binder.setBean()

@alexanoid
Copy link
Author

@mcollovati yes, I use Binder.setBean() method too

@tepi tepi self-assigned this Feb 19, 2024
@mshabarov mshabarov moved this from 🪵Product backlog to 🟢Ready to Go in Vaadin Flow ongoing work (Vaadin 10+) Feb 19, 2024
@tepi
Copy link
Contributor

tepi commented Feb 19, 2024

In at least 24.2 and 24.3, Binder.setBean() had a bug that allowed writing an invalid state to the bean since only the binding that had value change triggered would be validated, hence all the other required and empty fields which had not been touched were basically ignored, resulting into the bean being in an invalid state. This was fixed via #18535 which causes all the bindings to be validated on value change - which is causing the behavior seen here.

Quick fix for you is to use readBean and writeBean instead which should work as the buggy setBean before.

Current funtionality of setBean does not seem acceptable, but we can't roll back to previous implementation since setBean (like writeBean) should always guarantee the validity of the data written to the bean. I'll investigate if there's a way to only highlight the changed field if needed, but silenty validate all the bindings so we can keep that guarantee.

@tepi tepi moved this from 🟢Ready to Go to ⚒️ In progress in Vaadin Flow ongoing work (Vaadin 10+) Feb 19, 2024
@tepi tepi linked a pull request Feb 20, 2024 that will close this issue
@tepi tepi moved this from ⚒️ In progress to 🔎Iteration reviews in Vaadin Flow ongoing work (Vaadin 10+) Feb 20, 2024
@tepi tepi moved this from 🔖 High Priority (P1) to 🏗 WIP in Vaadin Flow bugs & maintenance (Vaadin 10+) Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants