diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index f406fcd31..0720d530a 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -1877,10 +1877,16 @@ export class LGraphCanvas implements ConnectionColorContext { // Right / aux button // Sticky select - won't remove single nodes - if (node) this.processSelect(node, e, true) + if (node) { + this.processSelect(node, e, true) + } else if (this.links_render_mode !== LinkRenderType.HIDDEN_LINK) { + // Reroutes + const reroute = graph.getRerouteOnPos(e.canvasX, e.canvasY) + if (reroute) this.processSelect(reroute, e, true) + } // Show context menu for the node or group under the pointer - this.processContextMenu(node, e) + pointer.onClick = () => this.processContextMenu(node, e) } this.last_mouse = [x, y] diff --git a/src/LiteGraphGlobal.ts b/src/LiteGraphGlobal.ts index a09f22d4c..3c373591f 100644 --- a/src/LiteGraphGlobal.ts +++ b/src/LiteGraphGlobal.ts @@ -788,22 +788,15 @@ export class LiteGraphGlobal { return hex } - closeAllContextMenus(ref_window: Window): void { - ref_window = ref_window || window - - const elements = ref_window.document.querySelectorAll(".litecontextmenu") + closeAllContextMenus(ref_window: Window = window): void { + const elements = [...ref_window.document.querySelectorAll(".litecontextmenu")] if (!elements.length) return - const results = [] for (const element of elements) { - results.push(element) - } - - for (const result of results) { - if ("close" in result && typeof result.close === "function") { - result.close() - } else if (result.parentNode) { - result.remove() + if ("close" in element && typeof element.close === "function") { + element.close() + } else { + element.remove() } } }