From 6efffd8c603f4765dacc10229703dffee3cc6d66 Mon Sep 17 00:00:00 2001 From: Balaji Sridharan Date: Mon, 24 Jun 2024 16:10:29 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Pass=20the=20default=20date=20to=20?= =?UTF-8?q?the=20getOnInputKeyDownStuff=20to=20avoid=20switching=20to=20th?= =?UTF-8?q?e=20next=20month=20view=20when=20the=20current=20date=20is=20in?= =?UTF-8?q?=20the=20last=20row=20of=20the=20current=20month?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Apply this fix as the render fails to rerender days to the next month view Closes #4934 --- src/test/datepicker_test.test.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/test/datepicker_test.test.tsx b/src/test/datepicker_test.test.tsx index e602ad6bc..e92e4a4a8 100644 --- a/src/test/datepicker_test.test.tsx +++ b/src/test/datepicker_test.test.tsx @@ -462,7 +462,10 @@ describe("DatePicker", () => { }); it("should update the preSelection state when a day is selected with Enter press", () => { - const data = getOnInputKeyDownStuff({ shouldCloseOnSelect: false }); + const data = getOnInputKeyDownStuff({ + shouldCloseOnSelect: false, + selected: "2024-06-06", + }); fireEvent.keyDown(data.dateInput, getKey(KeyType.ArrowDown)); const selectedDayNode = getSelectedDayNode(data.container); @@ -1039,8 +1042,9 @@ describe("DatePicker", () => { expect(document.body.querySelector("#portal-id-dom-test")).not.toBeNull(); }); - function getOnInputKeyDownStuff(opts = {}) { - const m = newDate(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + function getOnInputKeyDownStuff(opts: { [key: string]: any } = {}) { + const m = newDate(opts.selected); const copyM = newDate(m); const testFormat = "yyyy-MM-dd"; const exactishFormat = "yyyy-MM-dd hh: zzzz";