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

Investigate the feedback about the new validation behavior [2 days] #4167

Closed
vursen opened this issue Nov 22, 2022 · 5 comments
Closed

Investigate the feedback about the new validation behavior [2 days] #4167

vursen opened this issue Nov 22, 2022 · 5 comments

Comments

@vursen
Copy link
Contributor

vursen commented Nov 22, 2022

Let's inquire into the feedback we got about the new validation behavior to find out whether there are any issues that need to be fixed before enabling this behavior by default.

Related to vaadin/platform#3066

@vursen vursen self-assigned this Nov 22, 2022
@vursen
Copy link
Contributor Author

vursen commented Nov 22, 2022

Confirmed that date-picker has at least one issue with committing an invalid input when autoOpenDisabled. Created a ticket: vaadin/web-components#5066

@knoobie
Copy link
Contributor

knoobie commented Nov 24, 2022

I don't have time to test it properly, but an idea to be tested that it works:

  • You have a bean with a date property
  • You register the bean with a binder (using setBean) and mark this date field as required
  • User types a proper date and presses a save button: Expectation the server side date is stored and validation is successful
  • User changes the date to something unparseable like "Lorem" and presses save again: Expectation client side validation is failing AND the server side (already stored) representation is nulled so that the bean is also invalid

Edit: the required state is just an example for a server validation. A more real example is probably a range validation on the server where the user has to be 18-100 years. If the validation of the server isn't called with the nulled value the second time, it didn't know that the user changed something in the UI - even tho the UI shows an error from the client side validation

@vursen
Copy link
Contributor Author

vursen commented Nov 24, 2022

Thank you @knoobie for your input.

I tested DatePicker + Binder with this snippet today:

public static class Bean {
  private LocalDate value;

  public LocalDate getValue() {
      return value;
  }

  public void setValue(LocalDate value) {
      this.value = value;
  }
}

public DatePickerView() {
  Div value = new Div();

  DatePicker datePicker = new DatePicker("DatePicker");
  // datePicker.setAutoOpen(false);

  Binder<Bean> binder = new Binder<>(Bean.class);
  binder.forField(datePicker)
          .withValidator(date -> date.equals(LocalDate.of(2022, 1, 1)),
                  "Unexpected value")
          .withValidationStatusHandler(status -> {
              value.setText("Binder Value: " + status.getField().getValue());
          })
          .bind("property");

  Bean bean = new Bean();
  bean.setValue(LocalDate.of(2022, 1, 1));
  binder.setBean(bean);

  add(datePicker, value);
}

which confirmed that the value is correctly reset to null and the binder is properly notified both as long as autoOpen is true. When I set autoOpen to false, the value isn't reset and therefore the binder isn't notified either. This is all the same issue that was reported above.

@knoobie
Copy link
Contributor

knoobie commented Nov 24, 2022

Perfect! Thanks for confirmation!

@vursen
Copy link
Contributor Author

vursen commented Nov 25, 2022

Closing as vaadin/web-components#5066 was fixed.

@vursen vursen closed this as completed Nov 25, 2022
@vursen vursen changed the title Investigate the feedback about the new validation behavior Investigate the feedback about the new validation behavior [2 days] Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants