diff --git a/CHANGELOG.md b/CHANGELOG.md index f8a72ead3..1be15ddfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/reducers/tree.js b/src/reducers/tree.js index 9ce411cf8..6581364f3 100644 --- a/src/reducers/tree.js +++ b/src/reducers/tree.js @@ -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; } diff --git a/src/util/treeJsonProcessing.js b/src/util/treeJsonProcessing.js index 2c29f6152..39e7fc91a 100644 --- a/src/util/treeJsonProcessing.js +++ b/src/util/treeJsonProcessing.js @@ -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) => {