carbon-design-system / carbon

A design system built by IBM
https://www.carbondesignsystem.com
Apache License 2.0
7.88k stars 1.82k forks source link

[Bug]: DatePicker Now Seems to Require Date for min and max and value #17063

Open dabrad26 opened 4 months ago

dabrad26 commented 4 months ago

Package

@carbon/react

Browser

Safari

Package version

1.62.1

React version

18.3.1

Description

The DatePicker component documents that it takes String or Number for minDate or maxDate however recently that does not work and it requires a Date class passed in. This was also recently true for the value prop.

I have changed out code to convert to Date() before passing into value, minDate or maxDate if set. However the docs and prop validation on Carbon's side need to be updated or the library should do the same conversion (if type of string or number convert to new Date().

Warning: Failed prop type: Invalid prop `minDate` supplied to `ForwardRef(DatePicker2)`, expected one of type [string, number].

I am marking as a higher severity as this was released as a breaking change and could break production usage if not caught. For us QA caught it and we converted to Date.

Reproduction/example

.

Steps to reproduce

Create date picker with value, minDate or maxDate

Suggested Severity

Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.

Application/PAL

Aspera

Code of Conduct

2nikhiltom commented 3 months ago

hey @dabrad26 ! Thank you for reporting this, could you recreate the issue on stackblitz

dabrad26 commented 3 months ago

Essentially the type info is wrong. The Date picker doesn't want to work with Strings and number (which is documented in Carbon) but needs a Date class for value, min, max...).

This is most likely coming from flatpickr that the DatePicker component is using.

https://stackblitz.com/edit/github-u4drws?file=src%2FApp.jsx