Skip to content
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

Dynamic search based select #213

Open
jroper opened this issue Nov 30, 2022 · 1 comment
Open

Dynamic search based select #213

jroper opened this issue Nov 30, 2022 · 1 comment

Comments

@jroper
Copy link

jroper commented Nov 30, 2022

This would probably be an entirely new feature. But, imagine you have a system with a million users stored in a database. And you want to select one based on a simple text search. Obviously, fetching a million users and rendering them in the select, and then using the searcher function to match them, is infeasible. Instead, you want the items that appear to be selected to be dynamic, using API calls to the backend to fetch the items based on what the user has typed so far. So, to implement it, instead of a static list of items, you'll have a callback:

func(input string) interface{}

This would have to use goroutines/channels to invoke the search in the background, while allowing the user to continue to enter text, so that after a user types a certain number of characters, it can immediately issue the search callback, and then continue to allow the user to type and refine the search, waiting till the previous callback has returned till it invokes the callback again with the currently input text (if different from the previous callback invocation).

Since Items in Select is currently interface{}, perhaps it could be possible to add this support to the existing select, I'm not sure if that would make sense or not.

@SimFG
Copy link

SimFG commented Dec 1, 2022

I have the same idea, and I am going to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants