From 386df089f30df494adf80cefd9ac5993afb90be9 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Mon, 2 Jan 2023 16:41:17 +0100 Subject: [PATCH] feat(ui) - cards - fixed an issue with card subtype selection --- .../MetricSubtypeDropdown/MetricSubtypeDropdown.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/app/components/Dashboard/components/WidgetForm/components/MetricSubtypeDropdown/MetricSubtypeDropdown.tsx b/frontend/app/components/Dashboard/components/WidgetForm/components/MetricSubtypeDropdown/MetricSubtypeDropdown.tsx index fe7d3a503..37e2b46ad 100644 --- a/frontend/app/components/Dashboard/components/WidgetForm/components/MetricSubtypeDropdown/MetricSubtypeDropdown.tsx +++ b/frontend/app/components/Dashboard/components/WidgetForm/components/MetricSubtypeDropdown/MetricSubtypeDropdown.tsx @@ -14,7 +14,7 @@ function MetricSubtypeDropdown(props: Props) { const { metricStore } = useStore(); const metric: any = metricStore.instance; - const options = React.useMemo(() => { + const options: any = React.useMemo(() => { const type = TYPES.find((i: MetricType) => i.slug === metric.metricType); if (type && type.subTypes) { const options = type.subTypes.map((i: MetricType) => ({ @@ -30,7 +30,9 @@ function MetricSubtypeDropdown(props: Props) { React.useEffect(() => { // @ts-ignore - setTimeout(() => props.onSelect({ name: 'metricOf', value: { value: options[0].value }}), 0) + if (options && !options.map(i => i.value).includes(metric.metricOf)) { + setTimeout(() => props.onSelect({ name: 'metricOf', value: { value: options[0].value }}), 0) + } }, [metric.metricType]) return options ? (