From b6af18f442cdcb9005079fabbea39008007c9e36 Mon Sep 17 00:00:00 2001 From: Emma Hodcroft Date: Mon, 27 Aug 2018 16:24:15 +0200 Subject: [PATCH] force default tree zoom to root --- src/actions/recomputeReduxState.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/actions/recomputeReduxState.js b/src/actions/recomputeReduxState.js index 5c5d98c5f..b3cd3a428 100644 --- a/src/actions/recomputeReduxState.js +++ b/src/actions/recomputeReduxState.js @@ -406,7 +406,7 @@ const modifyTreeStateVisAndBranchThickness = (oldState, tipSelected, cladeSelect oldState.selectedStrain = tipSelected; } if (cladeSelected) { - const cladeSelectedIdx = cladeNameToIdx(oldState.nodes, cladeSelected); + const cladeSelectedIdx = cladeSelected === 'root' ? 0 : cladeNameToIdx(oldState.nodes, cladeSelected); oldState.selectedClade = cladeSelected; newIdxRoot = applyInViewNodesToTree(cladeSelectedIdx, oldState); // tipSelectedIdx, oldState); } @@ -525,6 +525,8 @@ export const createStateFromQueryOrJSONs = ({ if (query.clade) { tree = modifyTreeStateVisAndBranchThickness(tree, undefined, query.clade, controls); + } else { /* if not specifically given in URL, zoom to root */ + tree = modifyTreeStateVisAndBranchThickness(tree, undefined, 'root', controls); } tree = modifyTreeStateVisAndBranchThickness(tree, query.s, undefined, controls); if (treeToo && treeToo.loaded) {