From 60222fd0e603675b2ce5393bfa54f0283eeab0b1 Mon Sep 17 00:00:00 2001 From: Mayur Marakana Date: Wed, 21 Feb 2024 07:19:17 -0800 Subject: [PATCH] fix default value data for spatiotemporal layer --- .../configs/package-time-slider2-config-time-slider.json | 2 +- packages/geoview-time-slider/src/time-slider.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/geoview-core/public/configs/package-time-slider2-config-time-slider.json b/packages/geoview-core/public/configs/package-time-slider2-config-time-slider.json index 75cd337b376..13df8aa475d 100644 --- a/packages/geoview-core/public/configs/package-time-slider2-config-time-slider.json +++ b/packages/geoview-core/public/configs/package-time-slider2-config-time-slider.json @@ -33,7 +33,7 @@ }, "locked": true, "reversed": true, - "defaultValue": "2024-02-20T15:48:00Z" + "defaultValue": "2024-02-21T12:54:00Z" }, { "layerPaths": ["MSI/msi-94-or-more"], diff --git a/packages/geoview-time-slider/src/time-slider.tsx b/packages/geoview-time-slider/src/time-slider.tsx index 49cd06899ea..586ad2d3242 100644 --- a/packages/geoview-time-slider/src/time-slider.tsx +++ b/packages/geoview-time-slider/src/time-slider.tsx @@ -91,11 +91,13 @@ export function TimeSlider(TimeSliderPanelProps: TimeSliderPanelProps) { const defaultValueIsArray = Array.isArray(sliderConfig?.defaultValue); if (defaultValueIsArray) { setValues(layerPath, [new Date(sliderConfig?.defaultValue[0]).getTime(), new Date(sliderConfig?.defaultValue[1]).getTime()]); - } else { + } else if (range.includes(sliderConfig?.defaultValue)) { setValues(layerPath, [new Date(sliderConfig?.defaultValue).getTime()]); + } else { + setValues(layerPath, [new Date(range[0]).getTime()]); } } - }, [config, layerPath, setValues]); + }, [config, layerPath, range, setValues]); const timeStampRange = range.map((entry: string | number | Date) => new Date(entry).getTime()); // Check if range occurs in a single day or year