From 329cc9ac9b0277cc625ed29fcc50046adb5daccf Mon Sep 17 00:00:00 2001 From: Maja Komel Date: Fri, 24 Feb 2023 20:42:35 +0100 Subject: [PATCH] Fix error on MAT when dates typed in manually --- components/aggregation/mat/Form.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/aggregation/mat/Form.js b/components/aggregation/mat/Form.js index be43b004c..32a10e357 100644 --- a/components/aggregation/mat/Form.js +++ b/components/aggregation/mat/Form.js @@ -205,7 +205,8 @@ export const Form = ({ onSubmit, testNames, query }) => { const since = watch('since') const until = watch('until') const timeGrainOptions = useMemo(() => { - if (!since || !until) return ['hour', 'day', 'week', 'month'] + const dateRegex = /^\d{4}-\d{2}-\d{2}$/ + if (!until.match(dateRegex) || !since.match(dateRegex)) return ['hour', 'day', 'week', 'month'] const diff = dayjs(until).diff(dayjs(since), 'day') if (diff < 8) { const availableValues = ['hour', 'day']