Show models above folders in child folders to avoid models from appearing to belong the grandchild folder, prevent creating empty <optgroup />s

This commit is contained in:
Olivia Godone-Maresca
2023-02-07 21:13:06 -05:00
parent e0f22d29e8
commit e7bf2ee58b
2 changed files with 11 additions and 7 deletions

View File

@ -1322,9 +1322,12 @@ async function getModels() {
}
modelField.appendChild(modelOption)
} else {
const modelGroup = document.createElement('optgroup')
modelGroup.label = path + modelName[0]
modelField.appendChild(modelGroup)
// Since <optgroup/>s can't be nested, don't show empty groups
if (modelName[1].some(child => typeof(child) == 'string')) {
const modelGroup = document.createElement('optgroup')
modelGroup.label = path + modelName[0]
modelField.appendChild(modelGroup)
}
modelName[1].forEach( createModelOptions(modelField, selectedModel, path + modelName[0] + "/" ) )
}
}