fix(ui): add custom option to <select> when model ID not in curated list (enables custom model IDs)
This commit is contained in:
11
static/ui.js
11
static/ui.js
@@ -258,6 +258,17 @@ function renderModelDropdown(){
|
|||||||
async function selectModelFromDropdown(value){
|
async function selectModelFromDropdown(value){
|
||||||
const sel=$('modelSelect');
|
const sel=$('modelSelect');
|
||||||
if(!sel||sel.value===value) { closeModelDropdown(); return; }
|
if(!sel||sel.value===value) { closeModelDropdown(); return; }
|
||||||
|
// If the value isn't in the option list (custom model ID), add a temporary option
|
||||||
|
// so sel.value assignment succeeds and the model chip shows the custom ID.
|
||||||
|
if(!Array.from(sel.options).some(o=>o.value===value)){
|
||||||
|
const opt=document.createElement('option');
|
||||||
|
opt.value=value;
|
||||||
|
opt.textContent=value.split('/').pop()||value;
|
||||||
|
opt.dataset.custom='1';
|
||||||
|
// Remove any previous custom option before adding new one
|
||||||
|
sel.querySelectorAll('option[data-custom]').forEach(o=>o.remove());
|
||||||
|
sel.appendChild(opt);
|
||||||
|
}
|
||||||
sel.value=value;
|
sel.value=value;
|
||||||
syncModelChip();
|
syncModelChip();
|
||||||
closeModelDropdown();
|
closeModelDropdown();
|
||||||
|
|||||||
Reference in New Issue
Block a user