vaadin/vaadin-date-picker

Inconsistent handling of invalid input

tepi opened this issue · 2 comments

tepi commented

Description

Tested at https://vaadin.com/components/vaadin-date-picker/html-examples/date-picker-basic-demos#date-picker

When entering invalid input, the date picker does not handle it consistently.

Expected outcome

Either reset to previous valid value every time, or let the invalid input remain in the text box every time.

Actual outcome

Seemingly random behavior

Steps to reproduce

  1. Type "foo" into an empty date picker, press enter
  2. This selects today's date (why?)
  3. Select all text, clear it and type "foo" again, press enter
  4. Now the field stays invalid and "foo" remains in the text box

You can repeat clearing the field and entering "foo" and the date picker will alternate between these two behaviors.

Browsers Affected

All

Discussed with @jouni and agreed that this should be fixed to align "enter" key behaviour with "outside click" behaviour:

  1. Type "foo" into a date picker, press enter
  2. The value should be "", datePicker.invalid should be true and the field should still display "foo"

Here's an example with the desired behaviour: https://glitch.com/edit/#!/titanium-meteorite

Make sure a change event gets dispatched when the value is set to "" after invalid value is applied