Skip to content

Commit

Permalink
Restore terminal branch click behaviour
Browse files Browse the repository at this point in the history
Clicking on terminal branches incorrectly behaved as if we had clicked
on the tip (the circle); the intended behaviour is for internal +
terminal branches to summarise the information the same way. This was
noticed in an issue comment
<#1752 (comment)>

The bug was introduced in f7e944d which
removed the ability to detect if a click occurred on a terminal node
(tip) or terminal branch.
  • Loading branch information
jameshadfield committed Feb 20, 2024
1 parent 9f3fddc commit 4d70916
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
16 changes: 9 additions & 7 deletions src/components/tree/infoPanels/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ const NodeClickedPanel = ({selectedNode, nodes, clearSelectedNode, colorings, ob
const panelStyle = { ...infoPanelStyles.panel};
panelStyle.maxHeight = "70%";
const isTerminal = !node.hasChildren;
const title = isTerminal ?
const isTip = !selectedNode.isBranch;

const title = isTip ?
node.name :
isTerminal ?
`Branch leading to ${node.name}` :
Expand All @@ -259,19 +261,19 @@ const NodeClickedPanel = ({selectedNode, nodes, clearSelectedNode, colorings, ob
<StrainName>{title}</StrainName>
<table>
<tbody>
{!isTerminal && item(t("Number of terminal tips"), node.fullTipCount)}
{isTerminal && <VaccineInfo node={node} t={t}/>}
{!isTip && item(t("Number of terminal tips"), node.fullTipCount)}
{isTip && <VaccineInfo node={node} t={t}/>}
<SampleDate isTerminal={isTerminal} node={node} t={t}/>
{!isTerminal && item("Node name", node.name)}
{isTerminal && <PublicationInfo node={node} t={t}/>}
{!isTip && item("Node name", node.name)}
{isTip && <PublicationInfo node={node} t={t}/>}
{getTraitsToDisplay(node).map((trait) => (
<Trait node={node} trait={trait} colorings={colorings} key={trait} isTerminal={isTerminal}/>
))}
{isTerminal && <AccessionAndUrl node={node}/>}
{isTip && <AccessionAndUrl node={node}/>}
{item("", "")}
</tbody>
</table>
<MutationTable node={node} geneSortFn={geneSortFn} isTip={isTerminal} observedMutations={observedMutations}/>
<MutationTable node={node} geneSortFn={geneSortFn} isTip={isTip} observedMutations={observedMutations}/>
<p style={infoPanelStyles.comment}>
{t("Click outside this box to go back to the tree")}
</p>
Expand Down
4 changes: 2 additions & 2 deletions src/components/tree/reactD3Interface/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const onTipClick = function onTipClick(d) {
/* The order of these two dispatches is important: the reducer handling
`SELECT_NODE` must have access to the filtering state _prior_ to these filters
being applied */
this.props.dispatch({type: SELECT_NODE, name: d.n.name, idx: d.n.arrayIdx});
this.props.dispatch({type: SELECT_NODE, name: d.n.name, idx: d.n.arrayIdx, isBranch: false});
this.props.dispatch(applyFilter("add", strainSymbol, [d.n.name]));
};

Expand Down Expand Up @@ -60,7 +60,7 @@ export const onBranchClick = function onBranchClick(d) {
/* if a branch was clicked while holding the shift key, we instead display a node-clicked modal */
if (window.event.shiftKey) {
// no need to dispatch a filter action
this.props.dispatch({type: SELECT_NODE, name: d.n.name, idx: d.n.arrayIdx})
this.props.dispatch({type: SELECT_NODE, name: d.n.name, idx: d.n.arrayIdx, isBranch: true})
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/reducers/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const Controls = (state: ControlsState = getDefaultControlsState(), action): Con
const existingFilterInfo = (state.filters?.[strainSymbol]||[]).find((info) => info.value===action.name);
const existingFilterState = existingFilterInfo === undefined ? null :
existingFilterInfo.active ? 'active' : 'inactive';
return {...state, selectedNode: {name: action.name, idx: action.idx, existingFilterState}};
return {...state, selectedNode: {name: action.name, idx: action.idx, existingFilterState, isBranch: action.isBranch}};
}
case types.DESELECT_NODE: {
return {...state, selectedNode: null}
Expand Down

0 comments on commit 4d70916

Please sign in to comment.