Skip to content

Conversation

@tejas-fullstack
Copy link
Contributor


name: Pull Request
about: Create a pull request to improve this repository
title: "Fix: Calendar displays startDate as first month #5939"
labels: "bug"
assignees: ""

Description

Linked issue: #5939

Problem
The calendar in react-datepicker does not display the startDate as the first month when a date range is selected or when a preselected date is set. Users expected the calendar to open showing the startDate as the first visible month.

Changes

  • Added handling for selectsRange and monthSelectedIn state to ensure the calendar opens at the startDate.
  • Updated componentDidUpdate to reset monthSelectedIn when selectsRange is true.
  • Added relevant tests to confirm calendar behavior for startDate selection.

Screen Recorder

fix-5939.mp4

To reviewers

  • Verify that the calendar opens with the startDate as the first visible month.
  • Check that no regression occurs for single-date selection.

Contribution checklist

  • I have followed the contributing guidelines.
  • I have added sufficient test coverage for my changes.
  • I have formatted my code with Prettier and checked for linting issues with ESLint for code readability.

@martijnrusschen
Copy link
Member

Please checkout the failing CI job so we can proceed here.

@codecov
Copy link

codecov bot commented Nov 26, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.21%. Comparing base (877403c) to head (8283ac1).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5948   +/-   ##
=======================================
  Coverage   99.21%   99.21%           
=======================================
  Files          30       30           
  Lines        3579     3581    +2     
  Branches     1525     1530    +5     
=======================================
+ Hits         3551     3553    +2     
  Misses         27       27           
  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.

Adds a dedicated test to verify that monthSelectedIn is reset to 0
when selectsRange prop is enabled, ensuring the startDate is displayed
as the first month in range selection mode.

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

Co-Authored-By: Claude <[email protected]>
@martijnrusschen martijnrusschen merged commit ca268cf into Hacker0x01:main Nov 26, 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.

2 participants