-
Notifications
You must be signed in to change notification settings - Fork 83
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
Align field components behavior initially set as invalid with no constraints #4170
Comments
This approach doesn't seem to take into account the case when the developer removes all the constraints at the moment the component is already invalid (e.g. because its value didn't satisfy some of the removing constraints during previous validation). In that case, the component will stay invalid forever which is probably undesirable. |
Here is the original request for this feature in
So, the assumption is that developers might want to manage setting |
Just returning Scenario:
Expected: The field is valid. Needs to be figured out how we could work this around. |
Maybe instead of the |
This is actually not a correct strategy too as it will break the required case when we want to mark the field invalid only after the user has interacted with it. The user may focus and immediately blur the field, so the value won't be changed but the validation has to happen anyway to make the field red. Looking at this issue from different angles, I'm getting convinced that it is quite not feasible to support both the manual |
Describe your motivation
We have some misalignment in how
checkValidity()
is implemented in different field components.Some components have their own implementation, whereas others inherit from one of the mixins:
web-components/packages/field-base/src/input-constraints-mixin.js
Lines 49 to 54 in f4e19b7
web-components/packages/field-base/src/validate-mixin.js
Lines 57 to 59 in f4e19b7
This fact causes difference in what happens when pressing Tab to focus and then blur component that has
invalid
set as attribute without e.g.required
or other constraints, if applicable (pattern
,min
andmax
, etc).checkValidity()
inherited fromInputConstraintsMixin
(text-field, combo-box) do not re-validate on blur: the field remains invalid until user changes its value.checkValidity()
(date-picker, time-picker, select) or inherit fromValidateMixin
(radio-group) become valid on blur, without changing their valueExample
Describe the solution you'd like
Ideally, we should align all the components that have
checkValidity()
to only validate if constraints are provided.Otherwise, this logic should be executed to prevent resetting
invalid
state on blur orvalidate()
calls:web-components/packages/field-base/src/input-constraints-mixin.js
Line 53 in f4e19b7
The following components need to be updated:
vaadin-checkbox-group
vaadin-custom-field
vaadin-date-picker
vaadin-date-time-picker
vaadin-multi-select-combo-box
vaadin-radio-group
vaadin-select
vaadin-time-picker
See also #1750 which describes the same issue for
vaadin-date-picker
.The text was updated successfully, but these errors were encountered: