From f8d88d344cc1b637c6692056def09ed9e524c994 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Fri, 15 Apr 2022 20:35:29 +0200 Subject: [PATCH] fix(ui) - clickmaps breaking when there no events loaded --- .../PageInsightsPanel/PageInsightsPanel.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/app/components/Session_/PageInsightsPanel/PageInsightsPanel.tsx b/frontend/app/components/Session_/PageInsightsPanel/PageInsightsPanel.tsx index b83018c99..25170792d 100644 --- a/frontend/app/components/Session_/PageInsightsPanel/PageInsightsPanel.tsx +++ b/frontend/app/components/Session_/PageInsightsPanel/PageInsightsPanel.tsx @@ -21,7 +21,8 @@ interface Props { function PageInsightsPanel({ filters, fetchInsights, events = [], insights, urlOptions, host, loading = true }: Props) { - const [insightsFilters, setInsightsFilters] = useState(filters) + const [insightsFilters, setInsightsFilters] = useState(filters) + const defaultValue = (urlOptions && urlOptions[0]) ? urlOptions[0].value : '' const onDateChange = (e) => { const { startDate, endDate, rangeValue } = e; @@ -36,9 +37,11 @@ function PageInsightsPanel({ }, [insights]) useEffect(() => { - const url = insightsFilters.url ? insightsFilters.url : host + urlOptions[0].value; - Player.pause(); - fetchInsights({ ...insightsFilters, url }) + if (urlOptions && urlOptions[0]) { + const url = insightsFilters.url ? insightsFilters.url : host + urlOptions[0].value; + Player.pause(); + fetchInsights({ ...insightsFilters, url }) + } }, [insightsFilters]) const onPageSelect = (e, { name, value }) => { @@ -68,7 +71,7 @@ function PageInsightsPanel({ selection options={ urlOptions } name="url" - defaultValue={urlOptions[0].value} + defaultValue={defaultValue} onChange={ onPageSelect } id="change-dropdown" className="customDropdown"