From e3cfb275601e1d603596844a875f8f49f8f3f793 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Tue, 5 Nov 2024 12:43:50 +1300 Subject: [PATCH] Fix bug in narratives with filter changes When we constructed the initial controls state we essentially did ``` controls.defaults = { filters: {} }, controls.filters = controls.defaults.filters ``` and thus changing the current filter would also change the default. For narratives we need to be able to reset the default state, and since each value pointed to the same reference we ended up keeping the current state. --- src/reducers/controls.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reducers/controls.ts b/src/reducers/controls.ts index 5fc96bb77..c7361052c 100644 --- a/src/reducers/controls.ts +++ b/src/reducers/controls.ts @@ -110,8 +110,8 @@ export const getDefaultControlsState = () => { canRenderBranchLabels: true, analysisSlider: false, geoResolution: defaults.geoResolution, - filters: defaults.filters, - filtersInFooter: defaults.filtersInFooter, + filters: JSON.parse(JSON.stringify(defaults.filters)), + filtersInFooter: JSON.parse(JSON.stringify(defaults.filtersInFooter)), modal: null, quickdraw: false, // if true, components may skip expensive computes. mapAnimationDurationInMilliseconds: 30000, // in milliseconds