diff --git a/frontend/src/pages/Config.tsx b/frontend/src/pages/Config.tsx index 804d769..b0c12ab 100644 --- a/frontend/src/pages/Config.tsx +++ b/frontend/src/pages/Config.tsx @@ -338,18 +338,18 @@ function RiskProfilesCard() { function SaxoLinkPicker({ ticker, saxoSymbol }: { ticker: string; saxoSymbol: string | null }) { const [editing, setEditing] = useState(false) const [value, setValue] = useState(saxoSymbol ?? '') + const [showDropdown, setShowDropdown] = useState(false) const { mutate: setLink, isPending } = useSetWatchlistSaxoLink() const { data: catalogMatches } = useSaxoCatalog(undefined, value.length >= 2 ? value : undefined) - const datalistId = `saxo-symbols-${ticker}` - const save = () => { - const sym = value.trim().toUpperCase() || null - setLink({ ticker, saxoSymbol: sym }, { onSuccess: () => setEditing(false) }) + const save = (sym?: string) => { + const resolved = (sym ?? value).trim().toUpperCase() || null + setLink({ ticker, saxoSymbol: resolved }, { onSuccess: () => setEditing(false) }) } if (!editing) { return saxoSymbol ? ( - ) : ( @@ -360,21 +360,34 @@ function SaxoLinkPicker({ ticker, saxoSymbol }: { ticker: string; saxoSymbol: st } return ( -
+
setValue(e.target.value)} + onChange={e => { setValue(e.target.value); setShowDropdown(true) }} + onFocus={() => setShowDropdown(true)} onKeyDown={e => { if (e.key === 'Enter') save(); if (e.key === 'Escape') setEditing(false) }} - onBlur={save} - placeholder="Saxo symbol" - className="bg-dark-800 border border-slate-700/40 rounded px-1.5 py-0.5 text-[9px] text-white w-24 focus:outline-none focus:border-blue-500/50" + onBlur={() => save()} + placeholder="Search Saxo symbol…" + className="bg-dark-800 border border-slate-700/40 rounded px-1.5 py-0.5 text-[9px] text-white w-28 focus:outline-none focus:border-blue-500/50" /> - - {(catalogMatches ?? []).map((c: any) => )} - - {isPending && } + {isPending && } + {showDropdown && (catalogMatches ?? []).length > 0 && ( +
+ {(catalogMatches ?? []).map((c: any) => ( + + ))} +
+ )}
) }