web-components
web-components copied to clipboard
Field components should discard non-parsable programmatically set values / constraints, showing a warning
Motivation
Currently, the way field components handle non-parsable values or constraints is not consistent and user-friendly.
-
integer-field
resets values that don't match the integer pattern, showing a warning. -
date-picker
resets values that cannot be parsed to the default empty string, not showing any warning though. - ...
The same goes for constraints:
-
integer-field
just ignores non-integermin
andmax
, not showing any warning. -
date-picker
just ignores non-parsablemin
andmax
, not showing any warning. - ...
Solution
When setting a non-parsable value or constraint, the component should (a) discard it to the default one and (b) show a warning like:
<vaadin-date-picker> The `min` property must be a valid date but `{...}` was provided, so the property was reset to `{...}`.
Components
- [ ]
date-picker
- [ ]
time-picker
- [ ]
date-time-picker
- [ ]
integer-field
- [ ]
number-field
That feels like the opposite of https://github.com/vaadin/flow-components/issues/2466
That feels like the opposite of https://github.com/vaadin/flow-components/issues/2466
I might be wrong but the ticket you mentioned proposes a fallback parser in case the user enters something not typical into the input element. This ticket is however about setting the value
property which is always expected to follow a certain format (in the case of the listed components). Like, for example, the date-picker's value
property only allows ISO date strings.
You are right! I had the feeling the value
was the same as user entering value
- don't mind me :)