vaadin / flow-components

Java counterpart of Vaadin Web Components
100 stars 66 forks source link

Incorrect behavior when validating pre-filled text fields when navigating to the form from another view and clearing the text field. #5284

Open Bluezdrive opened 1 year ago

Bluezdrive commented 1 year ago

Describe the bug

For example, if you use a router link to navigate from a view to another view containing a prefilled form and delete the contents of a text field that must not be empty, when validating, only the required indicator turns red, but neither an error message is displayed nor the text field is colored red.

If you perform a page refresh on the form, everything works as expected.

I can send you my sample project!

Expected-behavior

Click on a button to navigate from a view to another view containing a prefilled form and delete the contents of a text field that must not be empty, when validating, the required indicator turns red, the text field is colored red, and an error message is displayed.

Reproduction

Prepare:

  1. Create a POJO containing String properties annotated with @NotEmpty.
  2. Create an EditView containing a FormLayout and a BeanValidationBinder for that POJO.
  3. EditView: For each of the String properties add a TextField and bind it by the property name.
  4. EditView: Pre-fill the form by using binder.readBean (e.g. in the setParameter method)
  5. EditView: Add a button with a click listener calling binder.writeBean
  6. Create another view containing a RouterLink(EditView.class, 1) navigation to the EditView and pre-filling the form. Execute:
  7. Open the view with the RouterLink and click on the link.
  8. The EditView opens and the form is pre-filled.
  9. Empty a TextField
  10. Click on the button => The validation passes and only the required indicator turns red.
  11. Refresh the page with the EditView (browser refresh) and the pre-filled form
  12. Empty a TextField
  13. Click on the button => Validation fails the required indicator turns red, the field is red and an error message is shown.

System Info

macOS, Vaadin 24.1.3, Safari 16.5.1

Bluezdrive commented 1 year ago

Unfortunately I can't host a sample, but I can send you a small sample project.

yuriy-fix commented 1 year ago

Dear @Bluezdrive, Please provide a link to a sample project.

Bluezdrive commented 1 year ago

This is a sample project to reproduce the issue.

my-app-24.zip