From 208393309c9f9ea4f79e462e2b823f04fe7f7c75 Mon Sep 17 00:00:00 2001 From: tejas-agravat-fullstack-dev Date: Mon, 20 Oct 2025 23:27:02 +0530 Subject: [PATCH 1/3] fix(calendar): display startDate as first month in range selection - Fixes issue #5939 --- src/index.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.tsx b/src/index.tsx index 5040c983b0..8b250b16b0 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -336,6 +336,9 @@ export class DatePicker extends Component { ) { this.setState({ monthSelectedIn: 0 }); } + if (this.props.selectsRange && this.state.monthSelectedIn !== 0) { + this.setState({ monthSelectedIn: 0 }); + } if (prevProps.highlightDates !== this.props.highlightDates) { this.setState({ highlightDates: getHighLightDaysMap(this.props.highlightDates), @@ -1518,6 +1521,8 @@ export class DatePicker extends Component { } render(): React.ReactElement | null { + console.log("Test"); + const calendar = this.renderCalendar(); if (this.props.inline) return calendar; From 087a513ee548c992ca39eef5d336987a5980318e Mon Sep 17 00:00:00 2001 From: tejas-agravat-fullstack-dev Date: Mon, 20 Oct 2025 23:46:50 +0530 Subject: [PATCH 2/3] Remove console --- src/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 8b250b16b0..4f4be4450f 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1521,8 +1521,6 @@ export class DatePicker extends Component { } render(): React.ReactElement | null { - console.log("Test"); - const calendar = this.renderCalendar(); if (this.props.inline) return calendar; From 8283ac17b7d670da2afb3a9e6f209c95e1ebc87e Mon Sep 17 00:00:00 2001 From: Martijn Russchen Date: Wed, 26 Nov 2025 11:46:37 +0100 Subject: [PATCH 3/3] test: add test for monthSelectedIn reset when selectsRange is true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/test/datepicker_test.test.tsx | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/test/datepicker_test.test.tsx b/src/test/datepicker_test.test.tsx index 10a58a83dc..fce4faf146 100644 --- a/src/test/datepicker_test.test.tsx +++ b/src/test/datepicker_test.test.tsx @@ -2843,6 +2843,39 @@ describe("DatePicker", () => { expect(instance!.state.monthSelectedIn).toEqual(0); }); + it("should set monthSelectedIn to 0 when selectsRange is true", () => { + let instance: DatePicker | null = null; + const { rerender } = render( + { + instance = node; + }} + monthsShown={2} + inline + />, + ); + expect(instance).toBeTruthy(); + act(() => { + ( + instance!.state as unknown as { monthSelectedIn: number } + ).monthSelectedIn = 1; + }); + expect(instance!.state.monthSelectedIn).toEqual(1); + + rerender( + { + instance = node; + }} + monthsShown={2} + inline + selectsRange + />, + ); + + expect(instance!.state.monthSelectedIn).toEqual(0); + }); + it("should disable non-jumping if prop focusSelectedMonth is true", () => { let instance: DatePicker | null = null; const { container } = render(