diff --git a/furniture-3d-system/src/app/supply-chain/new-products/1688-dropship-data/DropshipFieldFilter.tsx b/furniture-3d-system/src/app/supply-chain/new-products/1688-dropship-data/DropshipFieldFilter.tsx index d58432e9..a51587e2 100644 --- a/furniture-3d-system/src/app/supply-chain/new-products/1688-dropship-data/DropshipFieldFilter.tsx +++ b/furniture-3d-system/src/app/supply-chain/new-products/1688-dropship-data/DropshipFieldFilter.tsx @@ -35,6 +35,7 @@ type FilterGroupContextValue = { saving: boolean readPeriod: () => { dateFrom: string; dateTo: string; keyword: string } scheduleSelection: (field: Dropship1688FilterField, values: string[]) => void + cancelScheduledApply: () => void } const FilterGroupContext = createContext(null) @@ -173,6 +174,16 @@ export function DropshipFieldFilterGroup({ applyTimer.current = setTimeout(() => void flushApply(), APPLY_DEBOUNCE_MS) }, [flushApply]) + const cancelScheduledApply = useCallback(() => { + // Opening another filter is part of the same selection interaction. Keep the + // latest filter state queued until the user finishes choosing there instead + // of navigating with only the first field's condition. + if (applyTimer.current) { + clearTimeout(applyTimer.current) + applyTimer.current = null + } + }, []) + useEffect(() => () => { if (applyTimer.current) clearTimeout(applyTimer.current) }, []) @@ -202,6 +213,7 @@ export function DropshipFieldFilterGroup({ saving, readPeriod, scheduleSelection, + cancelScheduledApply, }}>
{children} @@ -237,6 +249,7 @@ export function DropshipFieldFilter({ saving, readPeriod, scheduleSelection, + cancelScheduledApply, } = group const fieldLabel = `${noun}筛选` const [open, setOpen] = useState(false) @@ -393,6 +406,7 @@ export function DropshipFieldFilter({ close() return } + cancelScheduledApply() const bounds = containerRef.current?.getBoundingClientRect() setAlignRight(Boolean(bounds && bounds.left + POPOVER_WIDTH + 8 > window.innerWidth)) setSelection(selected)