1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #3741 from Steve-Mcl/fix-context-menu

Fix context menu issues ready for v3 beta.5
This commit is contained in:
Nick O'Leary 2022-07-08 08:23:02 +01:00 committed by GitHub
commit 0682c346ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,10 +15,6 @@ RED.contextMenu = (function() {
// ], // ],
// width: 200, // width: 200,
// }) // })
} }
function disposeMenu() { function disposeMenu() {
@ -103,7 +99,7 @@ RED.contextMenu = (function() {
{ {
label: RED._("contextMenu.linkNodes"), label: RED._("contextMenu.linkNodes"),
onselect: 'core:split-wire-with-link-nodes', onselect: 'core:split-wire-with-link-nodes',
disabled: hasSelection || !hasLinks disabled: !hasLinks
} }
] ]
@ -111,22 +107,7 @@ RED.contextMenu = (function() {
} }
] ]
// menuItems.push(
// {
// label: (isSingleLink || isMultipleLinks)?'Insert into wire...':'Add node...',
// onselect: function() {
// RED.view.showQuickAddDialog({
// position: [ options.x - offset.left, options.y - offset.top ],
// touchTrigger: true,
// splice: isSingleLink?selection.links[0]:undefined,
// spliceMultiple: isMultipleLinks
// })
// }
// },
// )
// if (hasLinks && !hasSelection) {
// menuItems.push({ onselect: 'core:split-wires-with-junctions', label: 'Insert junction'})
// }
menuItems.push( menuItems.push(
null, null,
{ onselect: 'core:undo', disabled: RED.history.list().length === 0 }, { onselect: 'core:undo', disabled: RED.history.list().length === 0 },
@ -192,16 +173,17 @@ RED.contextMenu = (function() {
disposeMenu() disposeMenu()
}); });
menu.show(); menu.show();
// set focus to first item so that pressing escape key closes the menu
// menu.show({ $("#red-ui-workspace-context-menu :first(ul) > a").trigger("focus")
// target: $('#red-ui-main-container'),
// x: options.x,
// y: options.y
// })
} }
// Allow escape key hook and other editor events to close context menu
RED.keyboard.add("red-ui-workspace-context-menu", "escape", function () { RED.contextMenu.hide() })
RED.events.on("editor:open", function () { RED.contextMenu.hide() });
RED.events.on("search:open", function () { RED.contextMenu.hide() });
RED.events.on("type-search:open", function () { RED.contextMenu.hide() });
RED.events.on("actionList:open", function () { RED.contextMenu.hide() });
RED.events.on("view:selection-changed", function () { RED.contextMenu.hide() });
return { return {
show: show, show: show,
hide: disposeMenu hide: disposeMenu