From f56c7aee320b04b0e7746f07f748a0c0264bbe85 Mon Sep 17 00:00:00 2001 From: Wojciech Maj Date: Mon, 22 May 2023 20:23:01 +0200 Subject: [PATCH 1/2] Update Yarn to 3.5.1 --- package.json | 2 +- sample/yarn.lock | 10 +++++----- test/yarn.lock | 10 +++++----- yarn.lock | 12 ++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 66faab0b..49feb978 100644 --- a/package.json +++ b/package.json @@ -71,5 +71,5 @@ "url": "https://github.com/wojtekmaj/react-calendar.git" }, "funding": "https://github.com/wojtekmaj/react-calendar?sponsor=1", - "packageManager": "yarn@3.1.0" + "packageManager": "yarn@3.5.1" } diff --git a/sample/yarn.lock b/sample/yarn.lock index 72fa5181..202b4af5 100644 --- a/sample/yarn.lock +++ b/sample/yarn.lock @@ -2,7 +2,7 @@ # Manual changes might be lost - proceed with caution! __metadata: - version: 5 + version: 6 cacheKey: 8 "@ampproject/remapping@npm:^2.2.0": @@ -1025,7 +1025,7 @@ __metadata: "fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7" + resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" dependencies: node-gyp: latest conditions: os=darwin @@ -1719,7 +1719,7 @@ __metadata: "resolve@patch:resolve@^1.22.1#~builtin": version: 1.22.1 - resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" + resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d" dependencies: is-core-module: ^2.9.0 path-parse: ^1.0.7 @@ -1941,11 +1941,11 @@ __metadata: "typescript@patch:typescript@^5.0.0#~builtin": version: 5.0.4 - resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin::version=5.0.4&hash=ddd1e8" + resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin::version=5.0.4&hash=b5f058" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 6a1fe9a77bb9c5176ead919cc4a1499ee63e46b4e05bf667079f11bf3a8f7887f135aa72460a4c3b016e6e6bb65a822cb8689a6d86cbfe92d22cc9f501f09213 + checksum: d26b6ba97b6d163c55dbdffd9bbb4c211667ebebc743accfeb2c8c0154aace7afd097b51165a72a5bad2cf65a4612259344ff60f8e642362aa1695c760d303ac languageName: node linkType: hard diff --git a/test/yarn.lock b/test/yarn.lock index 0a8cab0b..eafb39ad 100644 --- a/test/yarn.lock +++ b/test/yarn.lock @@ -2,7 +2,7 @@ # Manual changes might be lost - proceed with caution! __metadata: - version: 5 + version: 6 cacheKey: 8 "@ampproject/remapping@npm:^2.2.0": @@ -1025,7 +1025,7 @@ __metadata: "fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7" + resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" dependencies: node-gyp: latest conditions: os=darwin @@ -1720,7 +1720,7 @@ __metadata: "resolve@patch:resolve@^1.22.1#~builtin": version: 1.22.1 - resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" + resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d" dependencies: is-core-module: ^2.9.0 path-parse: ^1.0.7 @@ -1942,11 +1942,11 @@ __metadata: "typescript@patch:typescript@^5.0.0#~builtin": version: 5.0.4 - resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin::version=5.0.4&hash=ddd1e8" + resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin::version=5.0.4&hash=b5f058" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 6a1fe9a77bb9c5176ead919cc4a1499ee63e46b4e05bf667079f11bf3a8f7887f135aa72460a4c3b016e6e6bb65a822cb8689a6d86cbfe92d22cc9f501f09213 + checksum: d26b6ba97b6d163c55dbdffd9bbb4c211667ebebc743accfeb2c8c0154aace7afd097b51165a72a5bad2cf65a4612259344ff60f8e642362aa1695c760d303ac languageName: node linkType: hard diff --git a/yarn.lock b/yarn.lock index 47e68bbe..528b3c8e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # Manual changes might be lost - proceed with caution! __metadata: - version: 5 + version: 6 cacheKey: 8 "@adobe/css-tools@npm:^4.0.1": @@ -2229,7 +2229,7 @@ __metadata: "fsevents@patch:fsevents@~2.3.2#~builtin": version: 2.3.2 - resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=18f3a7" + resolution: "fsevents@patch:fsevents@npm%3A2.3.2#~builtin::version=2.3.2&hash=df0bf1" dependencies: node-gyp: latest conditions: os=darwin @@ -4101,7 +4101,7 @@ __metadata: "resolve@patch:resolve@^1.22.1#~builtin": version: 1.22.1 - resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=07638b" + resolution: "resolve@patch:resolve@npm%3A1.22.1#~builtin::version=1.22.1&hash=c3c19d" dependencies: is-core-module: ^2.9.0 path-parse: ^1.0.7 @@ -4114,7 +4114,7 @@ __metadata: "resolve@patch:resolve@^2.0.0-next.4#~builtin": version: 2.0.0-next.4 - resolution: "resolve@patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=07638b" + resolution: "resolve@patch:resolve@npm%3A2.0.0-next.4#~builtin::version=2.0.0-next.4&hash=c3c19d" dependencies: is-core-module: ^2.9.0 path-parse: ^1.0.7 @@ -4694,11 +4694,11 @@ __metadata: "typescript@patch:typescript@^5.0.0#~builtin": version: 5.0.4 - resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin::version=5.0.4&hash=ddd1e8" + resolution: "typescript@patch:typescript@npm%3A5.0.4#~builtin::version=5.0.4&hash=b5f058" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 6a1fe9a77bb9c5176ead919cc4a1499ee63e46b4e05bf667079f11bf3a8f7887f135aa72460a4c3b016e6e6bb65a822cb8689a6d86cbfe92d22cc9f501f09213 + checksum: d26b6ba97b6d163c55dbdffd9bbb4c211667ebebc743accfeb2c8c0154aace7afd097b51165a72a5bad2cf65a4612259344ff60f8e642362aa1695c760d303ac languageName: node linkType: hard From 64467ee4500506653ae575b5ff0fa4bf4c0eb2b7 Mon Sep 17 00:00:00 2001 From: Tim Finucane Date: Tue, 23 May 2023 16:06:02 +1000 Subject: [PATCH 2/2] Fix and test turning goToRangeStartOnSelect off --- src/Calendar.spec.tsx | 79 +++++++++++++++++++++++++++++++++++++++++++ src/Calendar.tsx | 2 +- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/src/Calendar.spec.tsx b/src/Calendar.spec.tsx index 905e8d09..046ef755 100644 --- a/src/Calendar.spec.tsx +++ b/src/Calendar.spec.tsx @@ -707,6 +707,85 @@ describe('Calendar', () => { expect(onActiveStartDateChange).not.toHaveBeenCalled(); }); + + it('returns to start of range when range is completed', () => { + const onActiveStartDateChange = vi.fn(); + + const initialRange = new Date(2017, 0, 10); + + const { container } = render( + , + ); + + const nextMonthButton = container.querySelector( + 'button.react-calendar__navigation__next-button', + ) as HTMLButtonElement; + + act(() => { + nextMonthButton.click(); + }); + // Disregard the call on the above button click + onActiveStartDateChange.mockClear(); + + // First day not in the previous month + const firstDayTile = container.querySelector( + '.react-calendar__tile:not([react-calendar__month-view__days__day--weekend])', + ) as HTMLButtonElement; + + act(() => { + firstDayTile.click(); + }); + + expect(onActiveStartDateChange).toHaveBeenCalledWith( + expect.objectContaining({ + action: 'onChange', + activeStartDate: new Date(2017, 0, 1), + view: 'month', + }), + ); + }); + + it('does not change activeStartDate on range completion when goToRangeStartOnSelect is set to false', () => { + const onActiveStartDateChange = vi.fn(); + + const initialRange = new Date(2017, 0, 10); + + const { container } = render( + , + ); + + const nextMonthButton = container.querySelector( + 'button.react-calendar__navigation__next-button', + ) as HTMLButtonElement; + + act(() => { + nextMonthButton.click(); + }); + // Disregard the call on the above button click + onActiveStartDateChange.mockClear(); + + // First day not in the previous month + const firstDayTile = container.querySelector( + '.react-calendar__tile:not([react-calendar__month-view__days__day--weekend])', + ) as HTMLButtonElement; + + act(() => { + firstDayTile.click(); + }); + + expect(onActiveStartDateChange).not.toHaveBeenCalled(); + }); }); describe('handles view change properly', () => { diff --git a/src/Calendar.tsx b/src/Calendar.tsx index c7c5c435..3bdf0a5f 100644 --- a/src/Calendar.tsx +++ b/src/Calendar.tsx @@ -691,7 +691,7 @@ export default class Calendar extends Component { ...(this.props as CalendarPropsWithDefaults), value: nextValue, }) - : null; + : this.activeStartDate; event.persist();