From c648e1e8d621fd79e1494c921fe57c379e6ffc5a Mon Sep 17 00:00:00 2001 From: Steve-Mcl Date: Wed, 13 Jul 2022 12:42:55 +0100 Subject: [PATCH] fix context menu insert junc/links enabled state --- .../@node-red/editor-client/src/js/ui/contextMenu.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/contextMenu.js b/packages/node_modules/@node-red/editor-client/src/js/ui/contextMenu.js index 34a16d305..03517e65b 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/contextMenu.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/contextMenu.js @@ -30,11 +30,14 @@ RED.contextMenu = (function () { } const selection = RED.view.selection() + const noSelection = !selection || Object.keys(selection).length === 0 const hasSelection = (selection.nodes && selection.nodes.length > 0); const hasMultipleSelection = hasSelection && selection.nodes.length > 1; - const hasLinks = selection.links && selection.links.length > 0; - const isSingleLink = !hasSelection && hasLinks && selection.links.length === 1 - const isMultipleLinks = !hasSelection && hasLinks && selection.links.length > 1 + const virtulLinks = (selection.links && selection.links.filter(e => !!e.link)) || []; + const wireLinks = (selection.links && selection.links.filter(e => !e.link)) || []; + const hasLinks = wireLinks.length > 0; + const isSingleLink = !hasSelection && hasLinks && wireLinks.length === 1 + const isMultipleLinks = !hasSelection && hasLinks && wireLinks.length > 1 const canDelete = hasSelection || hasLinks const isGroup = hasSelection && selection.nodes.length === 1 && selection.nodes[0].type === 'group' @@ -66,12 +69,13 @@ RED.contextMenu = (function () { }) } }, - (hasSelection || hasLinks) ? { + (hasSelection || hasLinks) ? { // has nodes or at least 1 wire selected label: RED._("contextMenu.junction"), onselect: 'core:split-wires-with-junctions', disabled: !hasLinks } : { label: RED._("contextMenu.junction"), + disabled: !noSelection, // has 0 nodes, 0 links selected (i.e. workspace right click) onselect: function () { const nn = { _def: { defaults: {} },