From 9be5dc8281d7f246d26a3006998ab591e98accbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Z=C3=ADpek?= Date: Sun, 4 Sep 2022 11:16:29 +0200 Subject: [PATCH] Fixed filters bug --- .../DashboardHeader/components/DashboardFilters.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/client/src/pages/dashboard/components/DashboardHeader/components/DashboardFilters.tsx b/client/src/pages/dashboard/components/DashboardHeader/components/DashboardFilters.tsx index d54eb23..e6232a9 100644 --- a/client/src/pages/dashboard/components/DashboardHeader/components/DashboardFilters.tsx +++ b/client/src/pages/dashboard/components/DashboardHeader/components/DashboardFilters.tsx @@ -1,6 +1,7 @@ import { DateTimeInput } from '@/components/DateTimeInput' import { useFilterIntervals } from '@/pages/dashboard/hooks/useFilterIntervals' import { intervalToRange } from '@/utils/intervalToRange' +import { nextFrame } from '@/utils/nextFrame' import { useEffect, useState } from 'preact/hooks' import { useDashboardContext } from '../../../contexts/DashboardContext' @@ -41,11 +42,14 @@ export const DashboardFilters = ({ onClose }: Props) => { onClose?.() } - const setInterval = (interval: FilterInterval) => { + const setInterval = async (interval: FilterInterval) => { const range = intervalToRange(interval, value.customFrom, value.customTo) - setValue({ - ...value, + // preact bug again - starting to regret using it + await nextFrame() + + setFilter({ + ...preset, interval, customFrom: range[0], customTo: range[1],