From 9790c56020c656626edf82959606ac5f1ef80fa1 Mon Sep 17 00:00:00 2001 From: james hadfield Date: Mon, 5 Feb 2024 15:53:42 +1300 Subject: [PATCH] Remove node modal on filter removal Clicking a tip brings up a modal and activates the corresponding strain filter. Inactivating or removing this filter now also clears the modal. Closes #1243 --- src/reducers/controls.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/reducers/controls.ts b/src/reducers/controls.ts index b36b8c7ed..f25dc2866 100644 --- a/src/reducers/controls.ts +++ b/src/reducers/controls.ts @@ -248,8 +248,20 @@ const Controls = (state: ControlsState = getDefaultControlsState(), action): Con } else { // remove if no active+inactive filters delete filters[action.trait] } + + /* In the situation where a node-selected modal is active + we have + removed or inactivated the corresponding filter, then we want to remove + the modal */ + let selectedNode = state.selectedNode + if (selectedNode) { + const filterInfo = filters?.[strainSymbol]?.find((f)=>f.value===selectedNode.name); + if (!filterInfo || !filterInfo.active) { + selectedNode = null; + } + } return Object.assign({}, state, { - filters + filters, + selectedNode, }); } case types.TOGGLE_TEMPORAL_CONF: