From be708195c19450505de9466dc4ec490d266cca79 Mon Sep 17 00:00:00 2001 From: James Hadfield Date: Sat, 4 Aug 2018 17:28:20 -0700 Subject: [PATCH] fall back to default colorBy when valid --- src/actions/recomputeReduxState.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index 6bc9683f0..9962b7bc8 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -274,7 +274,12 @@ const checkAndCorrectErrorsInState = (state, metadata, query) => { if (availableNonGenotypeColorBys.indexOf("gt") > -1) { availableNonGenotypeColorBys.splice(availableNonGenotypeColorBys.indexOf("gt"), 1); } - if (availableNonGenotypeColorBys.length) { + + if (metadata.defaults && metadata.defaults.colorBy && availableNonGenotypeColorBys.indexOf(metadata.defaults.colorBy) !== -1) { + console.warn("colorBy falling back to", metadata.defaults.colorBy); + state.colorBy = metadata.defaults.colorBy; + state.defaults.colorBy = metadata.defaults.colorBy; + } else if (availableNonGenotypeColorBys.length) { console.error("Error detected trying to set colorBy to", state.colorBy, "falling back to", availableNonGenotypeColorBys[0]); state.colorBy = availableNonGenotypeColorBys[0]; state.defaults.colorBy = availableNonGenotypeColorBys[0];