Skip to content

Commit

Permalink
Clarify button active conditions
Browse files Browse the repository at this point in the history
- `treeIsZoomed` is ambiguous since the condition considers two trees.
  Rename to `anyTreeZoomed`.
- `activeResetTreeButton` has the same condition as `anyTreeZoomed`.
  Reuse the existing variable.
  • Loading branch information
victorlin committed Oct 8, 2024
1 parent 1eedee4 commit 4b45f15
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/tree/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
}
};
Expand Down

0 comments on commit 4b45f15

Please sign in to comment.