Skip to content

Commit fdb8e06

Browse files
committed
fix: repair switching between nodes via links and buttons
1 parent 9e36804 commit fdb8e06

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

graph.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ function highlightElement(event) {
190190
}
191191

192192
function unhighlightNode(event, unselect) {
193+
if (unselect) {
194+
showDetails(null, null);
195+
}
193196
if (! highlighted_node)
194197
return;
195198
// Swap out center/uncenter buttons
@@ -253,9 +256,6 @@ function unhighlightNode(event, unselect) {
253256
};
254257

255258
return_graph_to_init();
256-
if (unselect) {
257-
showDetails(null, null);
258-
}
259259
}
260260

261261
function updateHighlights() {

index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function showDetails(data, connected) {
3232
details_bottom.innerHTML += "<h3 class='mt-3'>List of simulators</h2>";
3333
for (const sim of SIMULATORS) {
3434
const quoted_sim = `[id='${sim}']`;
35-
details_bottom.innerHTML += `<button class='btn btn-secondary m-1' onclick="cy.nodes('#simulators').unselect(); let node = cy.nodes('${quoted_sim.replace(/'/g, "\\'")}'); node.select(); showNodeDetails(node);">${TOOL_DESCRIPTIONS[sim].short_name}</button>`;
35+
details_bottom.innerHTML += `<button class='btn btn-secondary m-1' onclick="cy.nodes().selectify(); cy.nodes('#simulators').unselect(); let node = cy.nodes('${quoted_sim.replace(/'/g, "\\'")}'); node.select(); cy.nodes().unselectify(); showNodeDetails(node);">${TOOL_DESCRIPTIONS[sim].short_name}</button>`;
3636
}
3737
details_bottom.innerHTML += "</div>";
3838
window.history.pushState({}, "", window.location.href.split("?")[0]);
@@ -84,8 +84,11 @@ function showDetails(data, connected) {
8484
}
8585
targetLink.addEventListener("click",function(e) {
8686
console.log("Clicked on " + targetLink.innerHTML);
87-
cy.nodes("[id='" + data.id + "']").unselect();
87+
cy.nodes().selectify();
88+
cy.nodes(":selected").unselect();
8889
cy.nodes("[id='" + targetLink.innerHTML + "']").select();
90+
showNodeDetails(cy.nodes("[id='" + targetLink.innerHTML + "']"));
91+
cy.nodes().unselectify();
8992
});
9093
targetLink.innerHTML = targetId;
9194
const simName = document.createElement("i");
@@ -133,7 +136,7 @@ function showDetails(data, connected) {
133136
<path d="M8 4.466V.534a.25.25 0 0 0-.41-.192L5.23 2.308a.25.25 0 0 0 0 .384l2.36 1.966A.25.25 0 0 0 8 4.466"/>
134137
</svg>&nbsp;Back to simulators`;
135138
back_button.classList.add("btn", "btn-secondary");
136-
back_button.onclick = function() { cy.nodes(`[id = '${data.id}']`).unselect(); cy.nodes("#simulators").select(); unhighlightNode(); };
139+
back_button.onclick = function() { cy.nodes().selectify(); cy.nodes(`[id = '${data.id}']`).unselect(); cy.nodes("#simulators").select(); cy.nodes().unselectify(); unhighlightNode(null, true); };
137140
back_p.appendChild(back_button);
138141
details_bottom.appendChild(back_p);
139142
// Edit footer

0 commit comments

Comments
 (0)