diff --git a/frontend/src/components/birth-date-picker.tsx b/frontend/src/components/birth-date-picker.tsx index f9514d2d..8dc3dd01 100644 --- a/frontend/src/components/birth-date-picker.tsx +++ b/frontend/src/components/birth-date-picker.tsx @@ -1,9 +1,10 @@ "use client"; import { format } from "date-fns"; -import { zhCN } from "date-fns/locale"; +import { zhCN as dateFnsZhCN } from "date-fns/locale"; import { CalendarIcon } from "lucide-react"; import { useId, useState } from "react"; +import { zhCN } from "react-day-picker/locale"; import { Button } from "@/components/ui/button"; import { Calendar } from "@/components/ui/calendar"; @@ -42,10 +43,10 @@ export function BirthDatePicker({ value, disabled, onChange }: BirthDatePickerPr {selected === undefined ? "选择出生日期" - : format(selected, "PPP", { locale: zhCN })} + : format(selected, "PPP", { locale: dateFnsZhCN })} - + { assert.match(picker, /startMonth=\{new Date\(1900, 0\)\}/) assert.match(picker, /reverseYears/) }) + +test("keeps the shadcn date-of-birth dropdown navigation order", () => { + // Given the shadcn Date of Birth composition + const picker = readFileSync(pickerUrl, "utf8") + + // When dropdown captions are enabled + // Then the picker must not move the full-width nav after the caption selects + assert.doesNotMatch(picker, /navLayout="after"/) +})