Open vursen opened 11 months ago
- Server-side validation is triggered on blur even if nothing has been typed
Note, also client side validation is triggered on blur even if nothing has been typed as seen here: https://github.com/vaadin/web-components/issues/6587
Note, also client side validation is triggered on blur even if nothing has been typed as seen here: https://github.com/vaadin/web-components/issues/6587
I'd like to clarify that this proposal focuses only on Flow components. It's specifically designed in a way that avoids modifying any existing behavior of the web components, such as validation on blur, for example. If you believe that the web components shouldn't validate on blur, feel free to create a separate ticket.
This refactor is planned to be delivered by 24.3-beta.
The refactor has covered all input components apart from DateTimePicker
which will have a separate refactor planned.
Motivation
There are several problems with the current approach based on the validated event:
All these problems have emerged after the introduction of the validated event, so we need to find an alternative. We should remember that the underlying purpose of the validated event was to trigger server-side validation when the user enters bad input, as there is no change event in that case.
Solution
For components that allow entering bad input, let’s replace the validated event with a new event
unparsable-change
:However, switching to the new event will address (4) only partially. The validation will be still inconsistent in eager mode: text fields will validate on input when entering valid values but on change when entering bad input. To improve this, let’s additionally subscribe the text field Flow components to
hasInputValue
property change and trigger validation when it occurs in eager mode.For the rest components, let's remove the validated event so that they will only validate on change event.
Affected components
Alternatives
Pros:
Cons:
Additional context
Related Github discussion: https://github.com/orgs/vaadin/discussions/4434
Related AC that introduced the validated event: https://github.com/vaadin/platform/issues/3066