Skip to content

Min/Max Date Fix#469

Merged
jbouder merged 2 commits intomainfrom
min-date-fix
Mar 3, 2026
Merged

Min/Max Date Fix#469
jbouder merged 2 commits intomainfrom
min-date-fix

Conversation

@jbouder
Copy link
Contributor

@jbouder jbouder commented Mar 3, 2026

Description

  • Ensure date picker can handle timestamp numbers as min/max.
  • Added unit tests

Related Issue

Resolves #468

Motivation and Context

  • Bug Fix

How Has This Been Tested?

  • Local Testing

Screenshots (if appropriate):

Copilot AI review requested due to automatic review settings March 3, 2026 13:27
@jbouder jbouder added the bug Something isn't working label Mar 3, 2026
@codecov
Copy link

codecov bot commented Mar 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.59%. Comparing base (e327e93) to head (f70957a).
⚠️ Report is 3 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and dateRange prop types to accept number (Unix timestamp in ms) in addition to Date | string.
  • Updated getDateString to handle the number type by wrapping it in new 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.

@jbouder jbouder requested a review from bapplejax March 3, 2026 13:35
@jbouder jbouder merged commit f67cc11 into main Mar 3, 2026
10 checks passed
@jbouder jbouder deleted the min-date-fix branch March 3, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DatePicker throws "p.toISOString is not a function" when passing min/max

3 participants