From d18fe930faaaf05ba786bcbd1dbb8a3efa25d480 Mon Sep 17 00:00:00 2001 From: Seve Badajoz Date: Wed, 3 Apr 2024 15:11:04 -0700 Subject: [PATCH 1/2] fix: remove implict state toggling for spatial underlay in favor of explict state setting --- client/src/components/embedding/index.tsx | 6 +++++- client/src/components/menubar/index.tsx | 3 +++ client/src/reducers/controls.ts | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/src/components/embedding/index.tsx b/client/src/components/embedding/index.tsx index e1e325135..0469ddd8a 100644 --- a/client/src/components/embedding/index.tsx +++ b/client/src/components/embedding/index.tsx @@ -46,9 +46,13 @@ class Embedding extends React.PureComponent<{}, EmbeddingState> { track(EVENTS.EXPLORER_LAYOUT_CHOICE_CHANGE_ITEM_CLICKED); dispatch(actions.layoutChoiceAction(e.currentTarget.value)); - if (imageUnderlay && e.target.value !== globals.spatialEmbeddingKeyword) { + if ( + imageUnderlay && + !e.target.value.includes(globals.spatialEmbeddingKeyword) + ) { dispatch({ type: "toggle image underlay", + toggle: false, }); } }; diff --git a/client/src/components/menubar/index.tsx b/client/src/components/menubar/index.tsx index 377aceb60..8adabae17 100644 --- a/client/src/components/menubar/index.tsx +++ b/client/src/components/menubar/index.tsx @@ -106,6 +106,7 @@ class MenuBar extends React.PureComponent<{}, State> { if (currentConditionMet) { dispatch({ type: "toggle image underlay", + toggle: true, }); } } @@ -123,6 +124,7 @@ class MenuBar extends React.PureComponent<{}, State> { if (!prevConditionMet && currentConditionMet) { dispatch({ type: "toggle image underlay", + toggle: true, }); } } @@ -438,6 +440,7 @@ class MenuBar extends React.PureComponent<{}, State> { onClick={() => { dispatch({ type: "toggle image underlay", + toggle: !imageUnderlay, }); }} /> diff --git a/client/src/reducers/controls.ts b/client/src/reducers/controls.ts index ebf40899d..e91532143 100644 --- a/client/src/reducers/controls.ts +++ b/client/src/reducers/controls.ts @@ -457,7 +457,7 @@ const Controls = ( case "toggle image underlay": { return { ...state, - imageUnderlay: !state.imageUnderlay, + imageUnderlay: action.toggle, }; } case "request uns metadata started": From b3f0f518d70b621ab6147311eafa0d825082dc1b Mon Sep 17 00:00:00 2001 From: Seve Badajoz Date: Thu, 4 Apr 2024 11:47:39 -0700 Subject: [PATCH 2/2] f/b --- client/src/reducers/controls.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/client/src/reducers/controls.ts b/client/src/reducers/controls.ts index e91532143..d708f4e4b 100644 --- a/client/src/reducers/controls.ts +++ b/client/src/reducers/controls.ts @@ -455,6 +455,7 @@ const Controls = ( Uns/Spatial **************************/ case "toggle image underlay": { + if (state.imageUnderlay === action.toggle) return state; return { ...state, imageUnderlay: action.toggle,