m-wrzr / streamlit-searchbox

Streamlit searchbox that dynamically updates and provides a list of suggestions based on a provided function
MIT License
253 stars 33 forks source link

Forces selection of first result #18

Closed sfc-gh-pkommini closed 1 year ago

sfc-gh-pkommini commented 1 year ago

Hi @m-wrzr Is there a way we can default to not select any of the results from the list and just submit the raw string submitted on the search?

Like in google I can select from the list or just enter and search using the raw sting. If you can point me on how to modify the default behavior. I can help submit a change.

Example:

image

In the above screenshot I just want to submit "Hi" but the list item 1 is automatically selected although I didn't explicitly select it.

In google, the first suggestion is actually just what I typed, and nothing more.

image

Is there a way to emulate this behavior? I would need to add the typed string to the list of suggestions and then default to the typed string for the selection.

sfc-gh-pkommini commented 1 year ago

@m-wrzr Could you review and let me know if this is acceptable?

sfc-gh-pkommini commented 1 year ago

Found that this can be addressed by returns the search term as part of the search function. Also, for it to appear at the start we need to add the searchterm at the start of the list that is returned as part of the search function.

sfc-gh-pkommini commented 1 year ago

Explanation is here.