diff --git a/web-common/src/features/dashboards/stores/dashboard-stores.ts b/web-common/src/features/dashboards/stores/dashboard-stores.ts index 51ef6a4168b..0d034178fcf 100644 --- a/web-common/src/features/dashboards/stores/dashboard-stores.ts +++ b/web-common/src/features/dashboards/stores/dashboard-stores.ts @@ -481,6 +481,9 @@ const metricsViewReducers = { metricsViewSpec: V1MetricsViewSpec, ) { updateMetricsExplorerByName(name, (metricsExplorer) => { + if (comparisonTimeRange) { + metricsExplorer.showTimeComparison = true; + } metricsExplorer.selectedComparisonTimeRange = comparisonTimeRange; AdvancedMeasureCorrector.correct(metricsExplorer, metricsViewSpec); }); diff --git a/web-common/src/features/dashboards/time-controls/comparison-pill/ComparisonPill.svelte b/web-common/src/features/dashboards/time-controls/comparison-pill/ComparisonPill.svelte index 4301b3e609e..e583653d36f 100644 --- a/web-common/src/features/dashboards/time-controls/comparison-pill/ComparisonPill.svelte +++ b/web-common/src/features/dashboards/time-controls/comparison-pill/ComparisonPill.svelte @@ -54,12 +54,6 @@ start: Date, end: Date, ) { - if (!showTimeComparison) { - metricsExplorerStore.displayTimeComparison( - $exploreName, - !showTimeComparison, - ); - } metricsExplorerStore.setSelectedComparisonRange( $exploreName, { diff --git a/web-common/src/features/dashboards/time-controls/time-control-store.ts b/web-common/src/features/dashboards/time-controls/time-control-store.ts index ed8859ef762..73f8fdd3b8b 100644 --- a/web-common/src/features/dashboards/time-controls/time-control-store.ts +++ b/web-common/src/features/dashboards/time-controls/time-control-store.ts @@ -19,8 +19,8 @@ import { getAdjustedFetchTime, } from "@rilldata/web-common/lib/time/ranges"; import { isoDurationToFullTimeRange } from "@rilldata/web-common/lib/time/ranges/iso-ranges"; -import type { DashboardTimeControls } from "@rilldata/web-common/lib/time/types"; import { + type DashboardTimeControls, TimeComparisonOption, type TimeRange, TimeRangePreset, @@ -419,7 +419,12 @@ function getComparisonTimeRange( name: comparisonOption, }; } - } else if (comparisonTimeRange.name === TimeComparisonOption.CUSTOM) { + } else if ( + comparisonTimeRange.name === TimeComparisonOption.CUSTOM || + // 1st step towards using a single `Custom` variable + // TODO: replace the usage of TimeComparisonOption.CUSTOM with TimeRangePreset.CUSTOM + comparisonTimeRange.name === TimeRangePreset.CUSTOM + ) { return comparisonTimeRange; } else { // variable time range of some kind.