Compare commits

...

6 Commits

Author SHA1 Message Date
Steve-Mcl
9729c89f5d ensure link-call cache is updated when link-in is modified
fixes #3694
depends on node-red-node-test-helper@0.3.0
2022-06-20 18:25:41 +01:00
Nick O'Leary
fc5a5f1b73 Merge pull request #3687 from node-red/space-in-strings
Fix handling of spacebar inside JSON visual editor
2022-06-17 10:05:12 +01:00
Nick O'Leary
226ab406b2 Merge pull request #3686 from node-red/fix-menu-padding
Fix menu padding to handle both icons and submenus
2022-06-17 10:05:01 +01:00
Nick O'Leary
9eaf5d82b6 Merge pull request #3685 from node-red/quick-add-offset
Include scroll offset when positioning quick-add dialog
2022-06-16 23:31:38 +01:00
Nick O'Leary
e3d6d242ac Fix handling of spacebar inside JSON visual editor
Fixes #3682

The treeList keyboard handling was consuming the event - used
to select the item in the list.

The fix here adds a 'selectable' flag on the treeList that can
be used to disabled (=false) the keyboard selection of items.
2022-06-16 23:29:46 +01:00
Nick O'Leary
1844633ff1 Include scroll offset when positioning quick-add dialog
Fixes #3684
2022-06-16 22:57:23 +01:00
6 changed files with 56 additions and 13 deletions

View File

@@ -111,7 +111,7 @@
"marked": "4.0.17",
"minami": "1.2.3",
"mocha": "9.2.2",
"node-red-node-test-helper": "^0.2.7",
"node-red-node-test-helper": "^0.3.0",
"nodemon": "2.0.16",
"proxy": "^1.0.2",
"sass": "1.52.3",

View File

@@ -21,6 +21,7 @@
* - multi : boolean - if true, .selected will return an array of results
* otherwise, returns the first selected item
* - sortable: boolean/string - TODO: see editableList
* - selectable: boolean - default true - whether individual items can be selected
* - rootSortable: boolean - if 'sortable' is set, then setting this to
* false, prevents items being sorted to the
* top level of the tree
@@ -118,6 +119,7 @@
switch(evt.keyCode) {
case 32: // SPACE
case 13: // ENTER
if (!that.options.selectable) { return }
if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) {
return
}

View File

@@ -534,6 +534,7 @@
var container = $("#red-ui-editor-type-json-tab-ui-container").css({"height":"100%"});
var filterDepth = Infinity;
var list = $('<div class="red-ui-debug-msg-payload red-ui-editor-type-json-editor">').appendTo(container).treeList({
selectable: false,
rootSortable: false,
sortable: ".red-ui-editor-type-json-editor-item-handle",
}).on("treelistchangeparent", function(event, evt) {

View File

@@ -1071,8 +1071,8 @@ RED.view = (function() {
var oy = point[1];
const offset = $("#red-ui-workspace-chart").offset()
var clientX = ox + offset.left
var clientY = oy + offset.top
var clientX = ox + offset.left - $("#red-ui-workspace-chart").scrollLeft()
var clientY = oy + offset.top - $("#red-ui-workspace-chart").scrollTop()
if (RED.settings.get("editor").view['view-snap-grid']) {
// eventLayer.append("circle").attr("cx",point[0]).attr("cy",point[1]).attr("r","2").attr('fill','red')

View File

@@ -109,16 +109,13 @@ module.exports = function(RED) {
},
remove(node) {
const target = generateTarget(node);
const tn = this.getTarget(target.name, target.flowId);
if (tn) {
const targs = this.getTargets(tn.name);
const idx = getIndex(targs, tn.id);
if (idx > -1) {
targs.splice(idx, 1);
}
if (targs.length === 0) {
delete registry.name[tn.name];
}
const targs = this.getTargets(target.name);
const idx = getIndex(targs, target.id);
if (idx > -1) {
targs.splice(idx, 1);
}
if (targs.length === 0) {
delete registry.name[tn.name];
}
delete registry.id[target.id];
},

View File

@@ -17,6 +17,7 @@
var should = require("should");
var linkNode = require("nr-test-utils").require("@node-red/nodes/core/common/60-link.js");
var helper = require("node-red-node-test-helper");
var clone = require("clone");
describe('link Node', function() {
@@ -319,6 +320,48 @@ describe('link Node', function() {
linkCall.receive({ payload: "hello", target: "double payload" });
});
})
it('should not raise error after deploying a name change to a duplicate link-in node', async function () {
this.timeout(400);
const flow = [
{ id: "tab-flow-1", type: "tab", label: "Flow 1" },
{ id: "link-in-1", z: "tab-flow-1", type: "link in", name: "duplicate", wires: [["link-out-1"]] },
{ id: "link-in-2", z: "tab-flow-1", type: "link in", name: "duplicate", wires: [["link-out-1"]] }, //duplicate name
{ id: "link-out-1", z: "tab-flow-1", type: "link out", mode: "return" },
{ id: "link-call", z: "tab-flow-1", type: "link call", linkType: "dynamic", links: [], wires: [["n4"]] },
{ id: "n4", z: "tab-flow-1", type: "helper" }
];
await helper.load(linkNode, flow)
const linkIn2before = helper.getNode("link-in-2");
linkIn2before.should.have.property("name", "duplicate") // check link-in-2 has been deployed with the duplicate name
//modify the flow and deploy change
const newConfig = clone(flow);
newConfig[2].name = "add" // change nodes name
await helper.setFlows(newConfig, "nodes") // deploy "nodes" only
const helperNode = helper.getNode("n4");
const linkCall2 = helper.getNode("link-call");
const linkIn2after = helper.getNode("link-in-2");
linkIn2after.should.have.property("name", "add") // check link-in-2 no longer has a duplicate name
//poke { payload: "hello", target: "add" } into the link-call node and
//ensure that a message arrives via the link-in node named "add"
await new Promise((resolve, reject) => {
helperNode.on("input", function (msg) {
try {
msg.should.have.property("target", "add");
msg.should.not.have.property("error");
resolve()
} catch (err) {
reject(err);
}
});
linkCall2.receive({ payload: "hello", target: "add" });
});
})
it('should allow nested link-call flows', function(done) {
this.timeout(500);
var flow = [/** Multiply by 2 link flow **/