palantir/blueprint

DateInput handles blur and key down Enter on the input field differently.

Open

#2550 aperta il 29 mag 2018

Vedi su GitHub
 (1 commento) (0 reazioni) (0 assegnatari)TypeScript (2167 fork)batch import
Package: datetimeType: enhancementhelp wanted

Metriche repository

Star
 (20.263 star)
Metriche merge PR
 (Merge medio 43g 10h) (27 PR mergiate in 30 g)

Descrizione

Environment

  • Package version(s): blueprintjs/datetime@2.0.0
  • Browser and OS versions: Chrome

Steps to reproduce

  1. With
<DateInput
  minDate={new Date('2018-01-01T00:00:00Z')}
  maxDate={new Date('2019-01-01T00:00:00Z')}
  onChange={val => console.log('onChange', val)}
  onError={val => console.log('onError', val)}
/>
  1. On filling in 05/29/3018 into the input as string and blurring the input, you see onError Fri May 29 3018 09:00:00 GMT+0200 (CEST)
  2. On filling in 05/29/3018 and then hitting Enter, you can see onChange Fri May 29 3018 09:00:00 GMT+0200 (CEST)

Actual behavior

Expected behavior

I would expect that whether input is blurred or whether I hit Enter, both ways will trigger the same handler, which according to documentation should be onError as date is out of range.

Possible solution

On handleInputBlur there is correct code that calls onChange or onError depending on the validity of the value but in handleDateChange which is called in handleInputKeyDown this is not implemented and onChange is called with invalid inputs.

Guida contributor