From 63b4615e78ae7a405bd053c5fa24c040ba13f288 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Mon, 23 Jun 2025 10:08:27 +0100 Subject: [PATCH] Add escape to clear suggested flow --- .../editor-client/src/js/ui/typeSearch.js | 5 +++-- .../@node-red/editor-client/src/js/ui/view.js | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js b/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js index 8b64a3231..dfaa55e76 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/typeSearch.js @@ -539,9 +539,10 @@ RED.typeSearch = (function() { } return { - show: show, + show, refresh: refreshTypeList, - hide: hide + hide, + isVisible: () => visible }; })(); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js index 1eec57f5b..ae470d63c 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/view.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/view.js @@ -876,6 +876,19 @@ RED.view = (function() { } }) + RED.actions.add("core:apply-suggested-flow", function() { + // TypeSeach will handle this if it is visible; don't want to cause conflicts + if (!RED.typeSearch.isVisible()) { + RED.view.applySuggestedFlow(); + } + }) + RED.actions.add("core:clear-suggested-flow", function() { + // TypeSeach will handle this if it is visible; don't want to cause conflicts + if (!RED.typeSearch.isVisible()) { + RED.view.setSuggestedFlow(null); + } + }) + RED.view.annotations.init(); RED.view.navigator.init(); RED.view.tools.init(); @@ -6613,6 +6626,7 @@ RED.view = (function() { __ghost: true }) } + $(window).on('keyup',disableSuggestedFlowEventHandler); } if (ghostNode) { if (suggestedNodes.length > 0) { @@ -6625,6 +6639,7 @@ RED.view = (function() { } function clearSuggestedFlow () { + $(window).off('keyup', disableSuggestedFlowEventHandler) currentSuggestion = null suggestedNodes = [] suggestedLinks = [] @@ -6670,6 +6685,12 @@ RED.view = (function() { } } + function disableSuggestedFlowEventHandler(evt) { + if (evt.keyCode === 27) { // ESCAPE + RED.actions.invoke("core:clear-suggested-flow") + } + } + return { init: init, state:function(state) {