Explorar el Código

fix(web): 对齐全部自然月占位样式

sy hace 2 días
padre
commit
c05016a35b

+ 2 - 1
web-scaffold/src/components/ui/month-filter.tsx

@@ -1,5 +1,6 @@
 import { useId, useRef, useState } from "react";
 import { ChevronLeft, ChevronRight } from "lucide-react";
+import { cn } from "../../lib/utils";
 import { FilterIcon } from "./filter-select";
 import "../../styles/month-filter.css";
 
@@ -32,7 +33,7 @@ export function MonthFilter({ value, onChange, maxMonth, allowAll = true, availa
     <button type="button" ref={trigger} className="filter-select month-filter-trigger" popoverTarget={id}
       aria-label={`自然月:${label}`} aria-haspopup="dialog" onClick={() => setYear(initialYear)}>
       <FilterIcon kind="month" />
-      <span className="filter-select-value">{label}</span>
+      <span className={cn("filter-select-value", !value && "is-placeholder")}>{label}</span>
     </button>
     <div id={id} ref={popup} popover="auto" role="dialog" aria-label="选择自然月" className="month-filter-popup">
       <div className="month-filter-heading">

+ 3 - 0
web-scaffold/src/pages/__tests__/settlement-statement-list.test.tsx

@@ -100,6 +100,7 @@ it("从页头导出,表格分开展示两种状态,改筛选时返回第一
 it.each(["", "?month=all"])("默认查询全部自然月并支持选月和重置(查询串 %j)", async (search) => {
   renderPage(search);
   const monthTrigger = screen.getByRole("button", { name: "自然月:全部自然月" });
+  expect(within(monthTrigger).getByText("全部自然月").classList.contains("is-placeholder")).toBe(true);
   await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: undefined })));
   await screen.findByRole("link", { name: "RECON-001" });
   fireEvent.click(screen.getByRole("button", { name: "导出当前结果" }));
@@ -114,9 +115,11 @@ it.each(["", "?month=all"])("默认查询全部自然月并支持选月和重置
   fireEvent.click(october);
   await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: "2026-10" })));
   expect(screen.getByRole("button", { name: "自然月:2026-10" })).toBe(monthTrigger);
+  expect(within(monthTrigger).getByText("2026-10").classList.contains("is-placeholder")).toBe(false);
 
   fireEvent.click(screen.getByRole("button", { name: "重置筛选" }));
   expect(screen.getByRole("button", { name: "自然月:全部自然月" })).toBe(monthTrigger);
+  expect(within(monthTrigger).getByText("全部自然月").classList.contains("is-placeholder")).toBe(true);
   await waitFor(() => expect(reconGetList).toHaveBeenLastCalledWith(expect.objectContaining({ period: undefined })));
 });