Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed URL query update when zooming out of selected, labelled subtree #1151

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/components/tree/reactD3Interface/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export const onBranchClick = function onBranchClick(d) {
// Can't use AA mut lists as zoom labels currently - URL is bad, but also, means every node has a label, and many conflict...
let legalBranchLabels;
// Check has some branch labels, and remove 'aa' ones.
// Check if the clicked branch is currently in view
// Determines whether to zoom into the clade or zoom out of it and whether to append or remove a clades label from the URL query
const isTargetBranchInView = (getIdxOfInViewRootNode(d.n) === d.n.arrayIdx);
if (d.n.branch_attrs &&
d.n.branch_attrs.labels !== undefined) {
legalBranchLabels = Object.keys(d.n.branch_attrs.labels).filter((label) => label !== "aa");
Expand All @@ -80,11 +83,11 @@ export const onBranchClick = function onBranchClick(d) {
);
// then use the first!
const key = legalBranchLabels[0];
cladeSelected = `${key}:${d.n.branch_attrs.labels[key]}`;
cladeSelected = isTargetBranchInView ? "" : `${key}:${d.n.branch_attrs.labels[key]}`;
}
/* Clicking on a branch means we want to zoom into the clade defined by that branch
_except_ when it's the "in-view" root branch, in which case we want to zoom out */
const arrayIdxToZoomTo = (getIdxOfInViewRootNode(d.n) === d.n.arrayIdx) ?
const arrayIdxToZoomTo = (isTargetBranchInView) ?
getParentBeyondPolytomy(d.n, this.props.distanceMeasure).arrayIdx :
d.n.arrayIdx;
if (d.that.params.orientation[0] === 1) root[0] = arrayIdxToZoomTo;
Expand Down