-
-
Notifications
You must be signed in to change notification settings - Fork 147
Description
Describe the bug
When we are using the getOptions function, it is returning correct dropdown data, but when we select any option, it set the input filed value to right option and then sets it to empty
To Reproduce
Steps to reproduce the behavior:
- use getOptions function to call api on query change
- on UI editing the input field, it shows the corect dropdown items
- select any item
- the input field will show it's name and then empties the input field.
Expected behavior
Selected item should be visible in input field
Desktop (please complete the following information):
- OS: windows 11
- Browser chrome
Additional context
Below is my getOptions function
function getOptions(query) { if(query === ''){ return [{name:'',value:''}] } return new Promise((resolve, reject) => { fetch(
https://www.alphavantage.co/query?function=SYMBOL_SEARCH&keywords=${query}&apikey={myapikey}`)
.then(response => response.json())
.then((resp) => {
var stocks = resp?.bestMatches?.filter(x=>x["4. region"]==="India/Bombay")
if(stocks)
resolve(stocks?.map(s=>{return {name:s["2. name"],value:s["1. symbol"]}}))
else
resolve([{name:'',value:''}])
})
.catch(reject);
});
}`
bug-compressed.zip