From 5bc8a00a3a88109781b7248b46851bde531cfc20 Mon Sep 17 00:00:00 2001 From: coder Date: Sat, 9 Mar 2024 16:09:41 +0800 Subject: [PATCH 1/2] fix: calendar-picker-view empty cell bug --- .../calendar-picker-view/calendar-picker-view.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/calendar-picker-view/calendar-picker-view.tsx b/src/components/calendar-picker-view/calendar-picker-view.tsx index 65643da8db..15bff8c11f 100644 --- a/src/components/calendar-picker-view/calendar-picker-view.tsx +++ b/src/components/calendar-picker-view/calendar-picker-view.tsx @@ -153,6 +153,11 @@ export const CalendarPickerView = forwardRef< year, month: month + 1, } + let emptyCount = + props.weekStartsOn === 'Monday' + ? monthIterator.date(1).isoWeekday() - 1 + : monthIterator.date(1).isoWeekday() + emptyCount = emptyCount % 7 cells.push(
@@ -166,11 +171,7 @@ export const CalendarPickerView = forwardRef<
{/* 空格填充 */} - {Array( - props.weekStartsOn === 'Monday' - ? monthIterator.date(1).isoWeekday() - 1 - : monthIterator.date(1).isoWeekday() - ) + {Array(emptyCount) .fill(null) .map((_, index) => (
From 675f32bc299bdd6a14e6efa3bb743ca3126a09dd Mon Sep 17 00:00:00 2001 From: coder Date: Mon, 11 Mar 2024 14:17:48 +0800 Subject: [PATCH 2/2] chore: test case --- .../calendar-picker-view.test.tsx.snap | 21 - .../config-provider.test.tsx.snap | 399 ------------------ 2 files changed, 420 deletions(-) diff --git a/src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap b/src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap index b0fa98624c..6b830f81d9 100644 --- a/src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap +++ b/src/components/calendar-picker-view/tests/__snapshots__/calendar-picker-view.test.tsx.snap @@ -6428,27 +6428,6 @@ exports[`Calendar jump to a day 2`] = `
-
-
-
-
-
-
-
diff --git a/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap b/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap index 7a0dd13fa0..a072e6e3bc 100644 --- a/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap +++ b/src/components/config-provider/tests/__snapshots__/config-provider.test.tsx.snap @@ -1747,27 +1747,6 @@ exports[`ConfigProvider should display the text as da-DK 1`] = `
-
-
-
-
-
-
-
@@ -6391,27 +6370,6 @@ exports[`ConfigProvider should display the text as en 1`] = `
-
-
-
-
-
-
-
@@ -11035,27 +10993,6 @@ exports[`ConfigProvider should display the text as es 1`] = `
-
-
-
-
-
-
-
@@ -15679,27 +15616,6 @@ exports[`ConfigProvider should display the text as fa-IR 1`] = `
-
-
-
-
-
-
-
@@ -20323,27 +20239,6 @@ exports[`ConfigProvider should display the text as fr-FR 1`] = `
-
-
-
-
-
-
-
@@ -24967,27 +24862,6 @@ exports[`ConfigProvider should display the text as hu 1`] = `
-
-
-
-
-
-
-
@@ -29611,27 +29485,6 @@ exports[`ConfigProvider should display the text as id-ID 1`] = `
-
-
-
-
-
-
-
@@ -34255,27 +34108,6 @@ exports[`ConfigProvider should display the text as it-IT 1`] = `
-
-
-
-
-
-
-
@@ -38899,27 +38731,6 @@ exports[`ConfigProvider should display the text as ja-JP 1`] = `
-
-
-
-
-
-
-
@@ -43543,27 +43354,6 @@ exports[`ConfigProvider should display the text as kk-KZ 1`] = `
-
-
-
-
-
-
-
@@ -48187,27 +47977,6 @@ exports[`ConfigProvider should display the text as ko-KR 1`] = `
-
-
-
-
-
-
-
@@ -52831,27 +52600,6 @@ exports[`ConfigProvider should display the text as nb-NO 1`] = `
-
-
-
-
-
-
-
@@ -57475,27 +57223,6 @@ exports[`ConfigProvider should display the text as nl-NL 1`] = `
-
-
-
-
-
-
-
@@ -62119,27 +61846,6 @@ exports[`ConfigProvider should display the text as ru 1`] = `
-
-
-
-
-
-
-
@@ -66763,27 +66469,6 @@ exports[`ConfigProvider should display the text as th-TH 1`] = `
-
-
-
-
-
-
-
@@ -71407,27 +71092,6 @@ exports[`ConfigProvider should display the text as tr-TR 1`] = `
-
-
-
-
-
-
-
@@ -76051,27 +75715,6 @@ exports[`ConfigProvider should display the text as zh-CH 1`] = `
-
-
-
-
-
-
-
@@ -80695,27 +80338,6 @@ exports[`ConfigProvider should display the text as zh-HK 1`] = `
-
-
-
-
-
-
-
@@ -85339,27 +84961,6 @@ exports[`ConfigProvider should display the text as zh-TW 1`] = `
-
-
-
-
-
-
-