diff --git a/src/pages/account-statuses.jsx b/src/pages/account-statuses.jsx index 8c576c7a..3cd1c0a6 100644 --- a/src/pages/account-statuses.jsx +++ b/src/pages/account-statuses.jsx @@ -319,7 +319,8 @@ function AccountStatuses() { min={MIN_YEAR_MONTH} max={new Date().toISOString().slice(0, 7)} onInput={(e) => { - const { value } = e.currentTarget; + const { value, validity } = e.currentTarget; + if (!validity.valid) return; setSearchParams( value ? { @@ -339,7 +340,8 @@ function AccountStatuses() { min={MIN_YEAR_MONTH} max={new Date().toISOString().slice(0, 7)} onInput={(e) => { - const { value } = e; + const { value, validity } = e; + if (!validity.valid) return; setSearchParams( value ? { @@ -478,6 +480,16 @@ function MonthPicker(props) { const monthFieldRef = useRef(); const yearFieldRef = useRef(); + const checkValidity = (month, year) => { + const [minYear, minMonth] = min?.split('-') || []; + const [maxYear, maxMonth] = max?.split('-') || []; + if (year < minYear) return false; + if (year > maxYear) return false; + if (year === minYear && month < minMonth) return false; + if (year === maxYear && month > maxMonth) return false; + return true; + }; + return (