Merge pull request #5301 from node-red/5245-filter-suggestions-for-known-types

Filter suggestions to ensure only known types are shown
This commit is contained in:
Nick O'Leary
2025-10-10 15:06:00 +01:00
committed by GitHub

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]