Skip to content

Commit

Permalink
Merge pull request #1845 from nextstrain/fix-new-metadata-tip-label
Browse files Browse the repository at this point in the history
Fix new metadata tip label
  • Loading branch information
joverlee521 authored Sep 10, 2024
2 parents dae78e7 + 90006cf commit 6ef1fe7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

* Fix bug where drag-and-drop metadata columns were no longer included as tip labels ([#1845](https://github.com/nextstrain/auspice/pull/1845))

## version 2.57.0 - 2024/08/30


Expand Down
9 changes: 7 additions & 2 deletions src/reducers/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,22 @@ const Tree = (state = getDefaultTreeState(), action) => {
});
case types.TREE_TOO_DATA:
return action.tree;
case types.ADD_EXTRA_METADATA:
case types.ADD_EXTRA_METADATA: {
// add data into `nodes` in-place, so no redux update will be triggered if you only listen to `nodes`
addNodeAttrs(state.nodes, action.newNodeAttrs);
// add the new nodeAttrKeys to ensure tip labels get updated
const nodeAttrKeys = new Set(state.nodeAttrKeys);
Object.keys(action.newColorings).forEach((attr) => nodeAttrKeys.add(attr));
// add the new colorings to totalStateCounts so that they can function as filters
return {
...state,
totalStateCounts: {
...state.totalStateCounts,
...countTraitsAcrossTree(state.nodes, Object.keys(action.newColorings), false, true)
}
},
nodeAttrKeys
};
}
default:
return state;
}
Expand Down
4 changes: 2 additions & 2 deletions src/util/treeJsonProcessing.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const pseudoRandomName = () => (Math.random()*1e32).toString(36).slice(0, 6);
* node.hasChildren {bool}
* node.arrayIdx {integer} - the index of the node in the nodes array
* @param {array} nodes redux tree nodes
* @return {Object} ret
* @return {Object} ret
* @return {Set} ret.nodeAttrKeys collection of all `node_attr` keys whose values are Objects
* @return {Array} ret.nodes input array (kinda unnecessary)
*
*
* side-effects: node.hasChildren (bool) and node.arrayIdx (INT) for each node in nodes
*/
const processNodes = (nodes) => {
Expand Down

0 comments on commit 6ef1fe7

Please sign in to comment.