Skip to content

Commit 8655f2f

Browse files
committed
Refactor: Use else if for mutually exclusive key checks
1 parent 7e615a1 commit 8655f2f

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Graph.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -260,29 +260,29 @@ class Graph extends React.Component {
260260
this.graphviz.removeDrawnEdge();
261261
this.unSelectComponents();
262262
}
263-
if (event.key === 'Delete') {
263+
else if (event.key === 'Delete') {
264264
this.deleteSelectedComponents.call(this);
265265
this.graphviz.removeDrawnEdge();
266266
}
267-
if (event.ctrlKey && event.key === 'c') {
267+
else if (event.ctrlKey && event.key === 'c') {
268268
let nodes = this.selectedComponents.filter('.node');
269269
if (nodes.size() > 0) {
270270
let nodeName = nodes.selectWithoutDataPropagation("title").text();
271271
this.latestNodeAttributes = this.dotGraph.getNodeAttributes(nodeName);
272272
}
273273
}
274-
if (event.ctrlKey && event.key === 'v') {
274+
else if (event.ctrlKey && event.key === 'v') {
275275
this.insertNodeWithLatestAttributes();
276276
}
277-
if (event.ctrlKey && event.key === 'x') {
277+
else if (event.ctrlKey && event.key === 'x') {
278278
let nodes = this.selectedComponents.filter('.node');
279279
if (nodes.size() > 0) {
280280
let nodeName = nodes.selectWithoutDataPropagation("title").text();
281281
this.latestNodeAttributes = this.dotGraph.getNodeAttributes(nodeName);
282282
}
283283
this.deleteSelectedComponents.call(this);
284284
}
285-
if (event.key === '?') {
285+
else if (event.key === '?') {
286286
this.props.onHelp();
287287
}
288288
this.isDrawingEdge = false;

0 commit comments

Comments
 (0)