carbon-design-system / carbon-components-angular

An Angular implementation of the Carbon Design System for IBM.
https://angular.carbondesignsystem.com
Apache License 2.0
531 stars 300 forks source link

[Bug]: Date picker - invalid manual input does not give error and is mapped to a wrong but valid date #2301

Open ngalan818 opened 1 year ago

ngalan818 commented 1 year ago

Detailed description

Describe in detail the issue you're having. Date picker will accept any manual input that has a number in it and will map it into a date without giving an error. Examples:

  • 02/29/2022 -> 03/01/2022
  • 99/99/2022 -> 06/07/2022
  • AA/AA/2022 -> 08/02/2027
  • A1 -> 01/01/2022
  • AA/AA/AAAA -> invalid, erased from the field

Is this a feature request (new component, new icon), a bug, or a general issue?

A bug

Is this issue related to a specific component?

Date picker

What did you expect to happen? What happened instead? What would you like to see changed?

All invalid inputs should also be erased from the field

What browser are you working in?

Firefox, Chrome

What version of the Carbon Design System are you using?

The latest version

Akshat55 commented 1 year ago

This is caused by the flatpickr implementation, not much we can do about this.

You can try passing in an errorHandler: (error) => { ... } in the flatpickrOptions & manually toggle invalid when errorHandler function is triggered.

Here is the reference in flatpickr repo, unfortunately, there is no reference in documentation 😞