From b036c3798b9a1c753d4432910264ed6508bc7dff Mon Sep 17 00:00:00 2001 From: dleadbetter Date: Mon, 12 Aug 2024 14:51:17 -0400 Subject: [PATCH] RC #291 - Updating FacetTimeline component to set new range when useRange value is changed --- packages/core-data/src/components/FacetTimeline.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/core-data/src/components/FacetTimeline.js b/packages/core-data/src/components/FacetTimeline.js index 04a94df6..06dd4755 100644 --- a/packages/core-data/src/components/FacetTimeline.js +++ b/packages/core-data/src/components/FacetTimeline.js @@ -168,6 +168,15 @@ const FacetTimeline = (props: Props) => { } }, [defaultMin, defaultMax, defaultRange]); + /** + * Sets the new range value based on the results of the `useRange` hook. + */ + useEffect(() => { + if (defaultRange && range && defaultRange.min !== range[0] && defaultRange.max !== range[1]) { + setRange([defaultRange.min, defaultRange.max]); + } + }, [defaultRange]); + /** * Only render if we have a default min/max value. */