Repository navigation
feat: integrate client-side validation into ComboBox - #4323
Conversation
| addCard("Helper text and helper component", div); | ||
| } | ||
|
|
||
| private void configurationForRequired() { |
There was a problem hiding this comment.
Seemingly unused test setup.
| import com.vaadin.flow.router.Route; | ||
|
|
||
| @Route("vaadin-combo-box/required-combobox") | ||
| public class RequiredComboboxPage extends Div { |
There was a problem hiding this comment.
Seemed to cover required and custom validation with Binder.
| import com.vaadin.flow.router.Route; | ||
|
|
||
| @Route("vaadin-combo-box/required-combobox-startup") | ||
| public class RequiredComboboxStartupPage extends Div { |
There was a problem hiding this comment.
Seemed to cover attaching initially invalid field.
| @Tag("validation-connector") | ||
| @JsModule("./src/validation-connector.js") | ||
| @Route("vaadin-combo-box/validation-connector") | ||
| public class ValidationConnectorErrorPage extends PolymerTemplate<TemplateModel> |
There was a problem hiding this comment.
This was a regression test for a client-side script error that occured when enabling required validation through the connector. Obsolete as the connector calls have been removed.
| } | ||
|
|
||
| @Test | ||
| public void required_customValuesAllowed_assertValidity() { |
There was a problem hiding this comment.
Added additional test where custom values are allowed. Probably doesn't make a difference to selecting a predefined value, as the test setup handling custom values is also just changing the component's value. Still can't hurt I guess?
|
|
||
| @Test | ||
| public void required_changeValue_assertValidity() { | ||
| $("input").id(EXPECTED_VALUE_INPUT).sendKeys("foo", Keys.ENTER); |
There was a problem hiding this comment.
I added custom validation to the Binder tests, as when allowing custom values, the user is mostly free to enter anything. This test does not allow custom values, just testing it here as well for completeness sake.
Also the test process differs a bit from the input field ones: For the input fields, custom validation was tested as part of the constraint tests. Combo box does not have any constraints, so I attempted to add this to the required tests.
| } | ||
|
|
||
| @Test | ||
| public void required_customValuesAllowed_changeValue_assertValidity() { |
There was a problem hiding this comment.
Additional test for required validation when allowing custom values.
| assertErrorMessage(UNEXPECTED_VALUE_ERROR_MESSAGE); | ||
|
|
||
| // Binder validation passes | ||
| testField.deselectAll(); |
There was a problem hiding this comment.
Multi-select combo box needs to be cleared after each step, otherwise it would just select additional values.
| } | ||
|
|
||
| @Override | ||
| public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) { |
There was a problem hiding this comment.
Removing this breaks binary compatibility (super method is in an interface instead of class). Should not be back-ported as is.
| /** | ||
| * Deselects all items, effectively clearing the value. | ||
| */ | ||
| public void deselectAll() { |
There was a problem hiding this comment.
Added convenience method for deselecting all values.
Another option would have been to override clear, however it didn't seem appropriate for clearing the selection, as the JavaDoc mentions that it's supposed to clear input elements specifically.
|
SonarCloud Quality Gate failed.
|
|
This ticket/PR has been released with Vaadin 24.0.0.alpha6 and is also targeting the upcoming stable 24.0.0 version. |









Description
Makes
ComboBoxandMultiSelectComboBoxvalidate on the server-side when the client attempts to validate, which means that server-side validation is now also triggered on blur. Also integrates with Binder, so that Binder validation is now also triggered when the component attempts to validate.Closes #4237
Closes #4238
Type of change