Skip to content

Commit b7921ac

Browse files
committed
feat(ui): add hotkey (H) for hover highlight toggle and clear states on disable
- Register 'h' hotkey in registerHotkeyEvents to toggle hover effect - Clear lingering highlight/dim states when disabling hover effect - Add (H) hint to button tooltips - Update tour: mention ✨ button in Workspaces step and H in shortcuts
1 parent 4d358f0 commit b7921ac

4 files changed

Lines changed: 27 additions & 6 deletions

File tree

src/graph/core.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,9 @@ class GraphCoreManager {
11571157
case "l":
11581158
await this.cache.ui.toggleLassoSelection();
11591159
break;
1160+
case "h":
1161+
await this.cache.ui.toggleHoverEffect(document.getElementById("hoverToggleBtn"));
1162+
break;
11601163
default:
11611164
break;
11621165
}

src/graph_lens_lite.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ <h3 id="appHeader" class="disabled-header" onclick="cache.ui.reloadApp()">
113113
<div class="button-separator"></div>
114114
<button class="small-btn" title="Fit graph to screen (F)" onclick="cache.gcm.fitViewToVisibleNodes()"></button>
115115
<button id="hideDisconnectedBtn" class="small-btn red" title="Hide all nodes and edges that are not connected to any other node or edge" onclick="cache.gcm.toggleCleanUpDanglingElements(this)">🚫</button>
116-
<button id="hoverToggleBtn" class="small-btn green highlight" title="Disable hover highlight effect" onclick="cache.ui.toggleHoverEffect(this)"></button>
116+
<button id="hoverToggleBtn" class="small-btn green highlight" title="Disable hover highlight effect (H)" onclick="cache.ui.toggleHoverEffect(this)"></button>
117117
<div id="debugDiv" class="inline"></div>
118118
<br>
119119
<h5 class="purple">Shown:

src/managers/ui.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,16 +479,33 @@ class UIManager {
479479
this.cache.CFG.DISABLE_HOVER_EFFECT = true;
480480
btn.classList.remove("green", "highlight");
481481
btn.classList.add("red");
482-
btn.title = "Enable hover highlight effect";
482+
btn.title = "Enable hover highlight effect (H)";
483483
const behaviors = await this.cache.graph.getBehaviors();
484484
const filtered = behaviors.filter(b => b.type !== this.cache.gcm.BEHAVIOURS.HOVER_ACTIVATE.type);
485485
await this.cache.graph.setBehaviors(filtered);
486+
487+
// Clear any lingering highlight/dim states from the hover behavior
488+
const stateMap = {};
489+
for (const node of this.cache.graph.getNodeData()) {
490+
const states = await this.cache.graph.getElementState(node.id);
491+
const cleaned = states.filter(s => s !== "highlight" && s !== "dim");
492+
if (cleaned.length !== states.length) stateMap[node.id] = cleaned;
493+
}
494+
for (const edge of this.cache.graph.getEdgeData()) {
495+
const states = await this.cache.graph.getElementState(edge.id);
496+
const cleaned = states.filter(s => s !== "highlight" && s !== "dim");
497+
if (cleaned.length !== states.length) stateMap[edge.id] = cleaned;
498+
}
499+
if (Object.keys(stateMap).length > 0) {
500+
await this.cache.graph.setElementState(stateMap);
501+
}
502+
486503
this.info("Hover highlight effect disabled");
487504
} else {
488505
this.cache.CFG.DISABLE_HOVER_EFFECT = false;
489506
btn.classList.remove("red");
490507
btn.classList.add("green", "highlight");
491-
btn.title = "Disable hover highlight effect";
508+
btn.title = "Disable hover highlight effect (H)";
492509
const behaviors = await this.cache.graph.getBehaviors();
493510
behaviors.push(this.cache.gcm.BEHAVIOURS.HOVER_ACTIVATE);
494511
await this.cache.graph.setBehaviors(behaviors);
@@ -502,11 +519,11 @@ class UIManager {
502519
if (this.cache.CFG.DISABLE_HOVER_EFFECT) {
503520
btn.classList.remove("green", "highlight");
504521
btn.classList.add("red");
505-
btn.title = "Enable hover highlight effect";
522+
btn.title = "Enable hover highlight effect (H)";
506523
} else {
507524
btn.classList.remove("red");
508525
btn.classList.add("green", "highlight");
509-
btn.title = "Disable hover highlight effect";
526+
btn.title = "Disable hover highlight effect (H)";
510527
}
511528
}
512529

src/utilities/tour.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ const TOUR_STEPS = [
138138
<br><br>
139139
Use the <strong class="tour-green">✚</strong> button to create a new workspace (clone or template-based), and the <strong class="tour-red">✗</strong> button to delete the current one.
140140
<br><br>
141-
The <strong>⛶</strong> button fits the graph to the screen, and <strong>🚫</strong> hides disconnected nodes.`,
141+
The <strong>⛶</strong> button fits the graph to the screen, <strong>🚫</strong> hides disconnected nodes, and <strong>✨</strong> toggles the hover highlight effect.`,
142142
target: "#workspaceContainer",
143143
position: "below",
144144
},
@@ -374,6 +374,7 @@ const TOUR_STEPS = [
374374
text: `That covers the main features. Here are some <strong>keyboard shortcuts</strong> to remember:
375375
<br><br>
376376
<strong>F</strong> — Fit graph to screen
377+
<br><strong>H</strong> — Toggle hover highlight effect
377378
<br><strong>L</strong> — Toggle lasso selection
378379
<br><strong>Q</strong> — Toggle query editor
379380
<br><strong>D</strong> — Toggle data editor

0 commit comments

Comments
 (0)