Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #469 +/- ##
=======================================
Coverage 99.59% 99.59%
=======================================
Files 51 51
Lines 997 997
Branches 346 346
=======================================
Hits 993 993
Misses 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug (issue #468) where the DatePicker component crashes with "p.toISOString is not a function" when minDate, maxDate, or dateRange is passed as a string (e.g., from Storybook controls). The root cause was that the internal getDateString helper only accepted string | Date, but when a string was coerced to a number by some callers (or a numeric timestamp was passed directly), it had no handling for the number type.
Changes:
- Extended the
minDate,maxDate, anddateRangeprop types to acceptnumber(Unix timestamp in ms) in addition toDate | string. - Updated
getDateStringto handle thenumbertype by wrapping it innew Date()before formatting, and added a JSDoc comment. - Added unit tests for all three props with numeric timestamp inputs.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
packages/comet-uswds/src/components/date-picker/date-picker.tsx |
Adds number to prop types for minDate, maxDate, dateRange; updates getDateString to accept/handle numbers; adds JSDoc. |
packages/comet-uswds/src/components/date-picker/date-picker.test.tsx |
Adds three new tests covering minDate, maxDate, and dateRange with numeric timestamp inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Related Issue
Resolves #468
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):