mirror of
https://github.com/node-red/node-red.git
synced 2025-12-27 23:34:38 +01:00
Don't require x/y when providing single node in suggestion api
This commit is contained in:
@@ -1747,15 +1747,11 @@ RED.view = (function() {
|
||||
suggest: function (suggestion) {
|
||||
if (suggestion?.nodes?.length > 0) {
|
||||
// Reposition the suggestion relative to the existing ghost node position
|
||||
const deltaX = suggestion.nodes[0].x - point[0]
|
||||
const deltaY = suggestion.nodes[0].y - point[1]
|
||||
const deltaX = (suggestion.nodes[0].x || 0) - point[0]
|
||||
const deltaY = (suggestion.nodes[0].y || 0) - point[1]
|
||||
suggestion.nodes.forEach(node => {
|
||||
if (Object.hasOwn(node, 'x')) {
|
||||
node.x = node.x - deltaX
|
||||
}
|
||||
if (Object.hasOwn(node, 'y')) {
|
||||
node.y = node.y - deltaY
|
||||
}
|
||||
node.x = (node.x || 0) - deltaX
|
||||
node.y = (node.y || 0) - deltaY
|
||||
})
|
||||
}
|
||||
setSuggestedFlow(suggestion);
|
||||
|
||||
Reference in New Issue
Block a user