Skip to content

Commit

Permalink
hotfix: rely on defenition of onDoubleClickNode to decide ttl for cli…
Browse files Browse the repository at this point in the history
…ck timer, lower tll for double click to be 280ms #481
  • Loading branch information
danielcaldas committed Jul 19, 2021
1 parent f8f993f commit b566a95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/components/graph/Graph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ export default class Graph extends React.Component {
onClickNode = clickedNodeId => {
const clickedNode = this.state.nodes[clickedNodeId];
if (!this.nodeClickTimer) {
// Note: onDoubleClickNode is not defined we don't need a long wait
// to understand weather a second click will arrive soon or not
// we can immediately trigger the click timer because we're 100%
// that the double click even is never intended
const ttl = this.props.onDoubleClickNode ? CONST.TTL_DOUBLE_CLICK_IN_MS : 0;
this.nodeClickTimer = setTimeout(() => {
if (this.state.config.collapsible) {
const leafConnections = getTargetLeafConnections(clickedNodeId, this.state.links, this.state.config);
Expand Down Expand Up @@ -398,7 +403,7 @@ export default class Graph extends React.Component {
this.props.onClickNode && this.props.onClickNode(clickedNodeId, clickedNode);
}
this.nodeClickTimer = null;
}, CONST.TTL_DOUBLE_CLICK_IN_MS);
}, ttl);
} else {
this.props.onDoubleClickNode && this.props.onDoubleClickNode(clickedNodeId, clickedNode);
this.nodeClickTimer = clearTimeout(this.nodeClickTimer);
Expand Down
2 changes: 1 addition & 1 deletion src/components/graph/graph.const.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export default {
},
LINK_CLASS_NAME: "link",
NODE_CLASS_NAME: "node",
TTL_DOUBLE_CLICK_IN_MS: 300,
TTL_DOUBLE_CLICK_IN_MS: 280,
...CONST,
};

0 comments on commit b566a95

Please sign in to comment.