New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
autocomplete search function #35
Comments
Hi @northkode ! Thanks for your recommendation. Like you, if in this days I can find some time, I will start to work on this 🚀 |
autoComplete must not be an array but rather a function because any application will fetch it from backend. As of now it is just an input field without autocomplete which is highly desirable. |
Hi @northkode @shivshankardayal What do you think its the best way to pass a function to a component? I understand 100% yours point on this feature. |
I changed const ac = await autoComplete();
var matchs = ac.filter(e => e.toLowerCase().includes(value.toLowerCase())).map(matchTag => { Sensible APIs would be async in nature so my function is as well. Thus I made If you want to further improve this you should accept an array of dicts which will also contain tag ids. The reason being tags will be stored in some sort of db with an id. So updating counts etc would be easier. You should look at the jquery token input plugin for example. Way back in 2013 when I made a minimal SO clone I used that jquery library. https://loopj.com/jquery-tokeninput/demo.html is the home page. |
Hi man, thanks for your reply. Sorry but I dont understand some things, I think that the idea is, for eg. My question is, how you get the value on the input to fetch the api and wait the results ? Do you have a working example to take a look? |
I've created a little repl and adjusted the Tags.svelte so that autoComplete accepts a function and fixed values https://svelte.dev/repl/92e971744653464d85ed45550576072b?version=3.32.1 |
Thanks a lot @Yahatix I added a prop to define a key to search if the results of the function is an array of objects. I will merge the branch tomorrow after some tests. |
Would be nice to be able to define the function the auto complete uses to find a matching value, not all payloads are just strings, being able to pass tags as objects with a title etc and having autocomplete just work would make a bit more sense with how most applications are built from an API perspective.
If I can find some time, i might make a PR
The text was updated successfully, but these errors were encountered: