Skip to content

Conversation

@martijnrusschen
Copy link
Member

Summary

  • Restore the native Date parsing fallback that was present in v7.x but accidentally removed in v8.0.0
  • When strictParsing is false (the default), flexible input formats like 12/05/2025 or 2025-12-16 3:31:01 PM are now parsed even when the dateFormat prop specifies a different format

Problem

In v8.0.0, the parseDate function was refactored and the native new Date(value) fallback was removed. This caused a regression where users could no longer type dates in flexible formats - only exact matches to the dateFormat prop were accepted.

Before v8 (working):

<DatePicker dateFormat="yyyy-MM-dd hh:mm aa" />
// User could type: "12/05/2025" ✅
// User could type: "2025-12-16 3:31:01 PM" ✅

v8.0.0+ (broken):

<DatePicker dateFormat="yyyy-MM-dd hh:mm aa" />
// User must type exact format: "2025-12-16 03:31 PM" 
// Other formats rejected ❌

Solution

Add back the native Date fallback when strictParsing is false. The fallback only triggers when:

  1. strictParsing is false (default)
  2. The input is at least 8 characters (to avoid parsing partial inputs like "03/" or "2000")
  3. date-fns parsing with the specified format(s) failed

Test plan

  • Added tests for native Date fallback behavior
  • All 1471 existing tests pass
  • Verified partial date inputs still work for calendar navigation

Fixes #6164

🤖 Generated with Claude Code

When strictParsing is false (the default), restore the native Date
parsing fallback that was present in v7.x but accidentally removed
in v8.0.0. This allows flexible input formats like "12/05/2025" or
"2025-12-16 3:31:01 PM" to be parsed even when the dateFormat prop
specifies a different format.

The fallback only triggers when:
1. strictParsing is false (default)
2. The input is at least 8 characters (to avoid parsing partial inputs)
3. date-fns parsing with the specified format(s) failed

This fixes the regression where v8.x required exact format matches
even with strictParsing disabled.

Fixes #6164

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.31%. Comparing base (1e9e151) to head (972a4b5).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6172      +/-   ##
==========================================
+ Coverage   99.26%   99.31%   +0.05%     
==========================================
  Files          30       30              
  Lines        3801     3805       +4     
  Branches     1652     1654       +2     
==========================================
+ Hits         3773     3779       +6     
+ Misses         27       25       -2     
  Partials        1        1              

☔ 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.

@martijnrusschen martijnrusschen merged commit 75a4ed1 into main Dec 18, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date format requirements are too strict after v8

2 participants