From 4b45f15bc0ab159af1411f5b396f6a846b6aefa1 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:51:58 -0700 Subject: [PATCH] Clarify button active conditions - `treeIsZoomed` is ambiguous since the condition considers two trees. Rename to `anyTreeZoomed`. - `activeResetTreeButton` has the same condition as `anyTreeZoomed`. Reuse the existing variable. --- src/components/tree/tree.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/tree/tree.js b/src/components/tree/tree.js index fd62f6174..f53ff72ce 100644 --- a/src/components/tree/tree.js +++ b/src/components/tree/tree.js @@ -116,18 +116,17 @@ class Tree extends React.Component { } getStyles = () => { - const activeResetTreeButton = this.props.tree.idxOfInViewRootNode !== 0 || - this.props.treeToo.idxOfInViewRootNode !== 0; - const filteredTree = !!this.props.tree.idxOfFilteredRoot && this.props.tree.idxOfInViewRootNode !== this.props.tree.idxOfFilteredRoot; const filteredTreeToo = !!this.props.treeToo.idxOfFilteredRoot && this.props.treeToo.idxOfInViewRootNode !== this.props.treeToo.idxOfFilteredRoot; const activeZoomButton = filteredTree || filteredTreeToo; - const treeIsZoomed = this.props.tree.idxOfInViewRootNode !== 0 || + const anyTreeZoomed = this.props.tree.idxOfInViewRootNode !== 0 || this.props.treeToo.idxOfInViewRootNode !== 0; + const activeResetTreeButton = anyTreeZoomed; + return { treeButtonsDiv: { zIndex: 100, @@ -152,9 +151,9 @@ class Tree extends React.Component { zoomOutButton: { zIndex: 100, display: "inline-block", - cursor: treeIsZoomed ? "pointer" : "auto", - color: treeIsZoomed ? darkGrey : lightGrey, - pointerEvents: treeIsZoomed ? "auto" : "none", + cursor: anyTreeZoomed ? "pointer" : "auto", + color: anyTreeZoomed ? darkGrey : lightGrey, + pointerEvents: anyTreeZoomed ? "auto" : "none", marginRight: "4px" } };