Skip to content

Conversation

@martijnrusschen
Copy link
Member

Fixes #3829

When using monthsShown >= 2 with a custom header, calling changeMonth() would produce inconsistent results depending on which calendar panel the user last selected a date in. This was because the monthSelectedIn state (which tracks the offset for multi-month display) was not being reset when changeMonth was explicitly called.

This fix:

  • Adds onMonthSelectedInChange callback prop to Calendar component
  • Resets monthSelectedIn to 0 when changeMonth is called, ensuring the target month always appears in the leftmost position
  • Adds test to verify the fix

Fixes #3829

When using monthsShown >= 2 with a custom header, calling changeMonth()
would produce inconsistent results depending on which calendar panel
the user last selected a date in. This was because the monthSelectedIn
state (which tracks the offset for multi-month display) was not being
reset when changeMonth was explicitly called.

This fix:
- Adds onMonthSelectedInChange callback prop to Calendar component
- Resets monthSelectedIn to 0 when changeMonth is called, ensuring
  the target month always appears in the leftmost position
- Adds test to verify the fix
@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.22%. Comparing base (bd3ab11) to head (fe8e4b8).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6058      +/-   ##
==========================================
+ Coverage   99.13%   99.22%   +0.08%     
==========================================
  Files          30       30              
  Lines        3586     3590       +4     
  Branches     1535     1519      -16     
==========================================
+ Hits         3555     3562       +7     
+ Misses         29       27       -2     
+ Partials        2        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.

Add test to verify that monthSelectedIn is reset to 0 when changeMonth
is called from a custom header. This ensures the fix for issue #3829
has complete test coverage.
@martijnrusschen martijnrusschen merged commit 928b2cf into main Nov 26, 2025
6 checks passed
@TravisJRyan
Copy link

Thank you!!

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.

changeMonth in custom header is inconsistent based on last selected date

3 participants