From a9a4ad0f6834e3805b7ea51776f2e13571091ea3 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 14 May 2026 09:45:34 -0700 Subject: [PATCH] Reset event property state when event changes --- .../[websiteId]/events/EventProperties.tsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/app/(main)/websites/[websiteId]/events/EventProperties.tsx b/src/app/(main)/websites/[websiteId]/events/EventProperties.tsx index b7b31b9c7..8328a19fc 100644 --- a/src/app/(main)/websites/[websiteId]/events/EventProperties.tsx +++ b/src/app/(main)/websites/[websiteId]/events/EventProperties.tsx @@ -1,16 +1,16 @@ 'use client'; import { Column, ComboBox, Grid, Label, ListItem, Row, Select } from '@umami/react-zen'; -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { LoadingPanel } from '@/components/common/LoadingPanel'; import { Panel } from '@/components/common/Panel'; import { useEventDataPropertiesQuery, useMessages } from '@/components/hooks'; -import { DATA_TYPE } from '@/lib/constants'; -import type { PropertyFilter } from '@/lib/types'; import { PropertyChart } from '@/components/property-data/PropertyChart'; import { PropertyDateChart } from '@/components/property-data/PropertyDateChart'; import { PropertyFilterBar } from '@/components/property-data/PropertyFilterBar'; import { PropertyFilterButton } from '@/components/property-data/PropertyFilterButton'; import { PropertyNumericChart } from '@/components/property-data/PropertyNumericChart'; +import { DATA_TYPE } from '@/lib/constants'; +import type { PropertyFilter } from '@/lib/types'; import { EventDataPivotTable } from '../event-data/EventDataPivotTable'; export function EventProperties({ websiteId }: { websiteId: string }) { @@ -19,6 +19,11 @@ export function EventProperties({ websiteId }: { websiteId: string }) { const [propertyFilters, setPropertyFilters] = useState([]); const { t, labels } = useMessages(); + useEffect(() => { + setPropertyName(''); + setPropertyFilters([]); + }, [eventName]); + const { data, isLoading, isFetching, error } = useEventDataPropertiesQuery(websiteId); const eventNames = useMemo(() => { @@ -126,11 +131,9 @@ export function EventProperties({ websiteId }: { websiteId: string }) { )} )} - {eventName && ( - - )} + {eventName && } {eventName && propertyName && ( - + {(selectedProperty?.dataType === DATA_TYPE.string || selectedProperty?.dataType === DATA_TYPE.boolean) && (