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

Filter suggestions to ensure only known types are shown
pull/5306/head
Nick O'Leary 2025-10-10 15:06:00 +01:00 committed by GitHub
commit e85476b925
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 0 deletions

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]