Filter suggestions to ensure only known types are shown

This commit is contained in:
Nick O'Leary
2025-10-10 12:02:36 +01:00
parent f60f12cf47
commit 00b879f855

View File

@@ -6543,6 +6543,18 @@ RED.view = (function() {
if (!Array.isArray(suggestion.nodes[0])) {
suggestion.nodes = [suggestion.nodes]
}
// Validate the suggestions only contain node types we recognise - filter out any we don't
suggestion.nodes = suggestion.nodes.filter(suggestedNodes => {
if (!Array.isArray(suggestedNodes)) {
suggestedNodes = [suggestedNodes]
}
suggestedNodes = suggestedNodes.filter(n => {
const def = RED.nodes.getType(n.type)
return !!def
})
return suggestedNodes.length > 0
})
suggestion.count = suggestion.nodes.length
suggestion.currentIndex = 0
suggestion.current = suggestion.nodes[suggestion.currentIndex]