fix(supply-chain): merge rapid 1688 field filters

This commit is contained in:
WuYongJie 2026-09-18 15:16:55 +08:00
parent 9244b9d570
commit 009685cdd7

View File

@ -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<FilterGroupContextValue | null>(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,
}}>
<div ref={groupRef} className={styles.dropshipFilterGroup}>
{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)