Skip to content

Commit

Permalink
[tanglegrams] ensure clip mask width > 0
Browse files Browse the repository at this point in the history
Fixes a browser-specific bug where the invalid <rect> would cause the
entire RHS tree to not be displayed.

Tested on Safari 17.4.1, Firefox 126 & Chrome 123

Closes #1755
  • Loading branch information
jameshadfield committed Jun 11, 2024
1 parent c11938d commit fcc3b68
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/tree/phyloTree/renderers.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ export const branchStrokeForHover = function branchStrokeForHover(d) {
* in practice, elements (or portions of elements) render outside this.
*/
export const setClipMask = function setClipMask() {
const [xMin, xMax, yMin, yMax] = [...this.xScale.range(), ...this.yScale.range()];
const [yMin, yMax] = this.yScale.range();
// for the RHS tree (if there is one) ensure that xMin < xMax, else width<0 which some
// browsers don't like. See <https://github.com/nextstrain/auspice/issues/1755>
let [xMin, xMax] = this.xScale.range();
if (xMin>xMax) [xMin, xMax] = [xMax, xMin];
const x0 = xMin - 5;
const width = xMax - xMin + 20; // RHS overflow is not problematic
const y0 = yMin - 15; // some overflow at top is ok
Expand Down

0 comments on commit fcc3b68

Please sign in to comment.