From d9628c64a819699f160e6ab895753d8ad14753cc Mon Sep 17 00:00:00 2001 From: james hadfield Date: Mon, 9 Mar 2020 15:36:53 +1300 Subject: [PATCH] Remove legend URL query upon user interaction This mirrors what we do for sidebar open state and prevents the URL query and the app state being out-of-sync --- src/components/tree/legend/legend.js | 1 + src/middleware/changeURL.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/components/tree/legend/legend.js b/src/components/tree/legend/legend.js index e2442e750..109d1ab1a 100644 --- a/src/components/tree/legend/legend.js +++ b/src/components/tree/legend/legend.js @@ -23,6 +23,7 @@ class Legend extends React.Component { } showLegend() { + // redux state takes precedent if (this.props.legendOpen !== undefined) { return this.props.legendOpen; } // Our default state changes based on the size of the window or the number of items in the legend. diff --git a/src/middleware/changeURL.js b/src/middleware/changeURL.js index 186924c66..250509731 100644 --- a/src/middleware/changeURL.js +++ b/src/middleware/changeURL.js @@ -81,6 +81,13 @@ export const changeURLMiddleware = (store) => (next) => (action) => { } break; } + case types.TOGGLE_LEGEND: { + // we treat this the same as sidebar above -- it can only be added to the URL manually + if ("legend" in query) { + query.legend = undefined; + } + break; + } case types.TOGGLE_PANEL_DISPLAY: { if (state.controls.panelsAvailable.length === action.panelsToDisplay.length) { query.d = undefined;