web-components icon indicating copy to clipboard operation
web-components copied to clipboard

Field components should discard non-parsable programmatically set values / constraints, showing a warning

Open vursen opened this issue 2 years ago • 3 comments

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-integer min and max, not showing any warning.
  • date-picker just ignores non-parsable min and max, 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

vursen avatar Jul 12 '22 20:07 vursen

That feels like the opposite of https://github.com/vaadin/flow-components/issues/2466

knoobie avatar Jul 13 '22 05:07 knoobie

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.

vursen avatar Jul 13 '22 06:07 vursen

You are right! I had the feeling the value was the same as user entering value - don't mind me :)

knoobie avatar Jul 13 '22 06:07 knoobie