diff --git a/apps/edr-freight-web/backoffice/src/components/filters/bodies/DateBody.tsx b/apps/edr-freight-web/backoffice/src/components/filters/bodies/DateBody.tsx index b2032170d..32970abef 100644 --- a/apps/edr-freight-web/backoffice/src/components/filters/bodies/DateBody.tsx +++ b/apps/edr-freight-web/backoffice/src/components/filters/bodies/DateBody.tsx @@ -15,7 +15,11 @@ import type { FilterBodyProps } from "./TextBody"; // i18n.language !== "en" branch here when this body is first wired into a // record-management page (Phase 4 of the filter-bar rollout). export function DateBody({ def, value, onChange, onClose }: FilterBodyProps) { - const [op, setOp] = useState(value?.op ?? DEFAULT_OP.date); + // DEFAULT_OP.date is always "between" — a def restricted to a single + // non-default operator (e.g. `operators: ["before"]` for an exact-date + // filter) would otherwise open on the range UI with no way to switch off + // it, since OperatorSelect hides itself when there's only one choice. + const [op, setOp] = useState(value?.op ?? def.operators?.[0] ?? DEFAULT_OP.date); // Mantine 9's date inputs speak `YYYY-MM-DD` strings, not Date objects. const [from, setFrom] = useState(value?.v[0]?.slice(0, 10) ?? null); const [to, setTo] = useState(value?.v[1]?.slice(0, 10) ?? null);