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

How to customize the search, like calling search function only when user typed search? #64

Open
kranthi419 opened this issue Sep 20, 2024 · 2 comments

Comments

@kranthi419
Copy link

No description provided.

@m-wrzr
Copy link
Owner

m-wrzr commented Oct 4, 2024

Hey, can you provide more details on how you're using st_searchbox? the search function should only be called when the user is typing something, e.g.

import streamlit as st

from streamlit_searchbox import st_searchbox


def search(searchterm: str):
    # this will only be called when the user types something
    print(f"searching for {searchterm}")
    return [f"{searchterm}_{i}" for i in range(10)]


result = st_searchbox(search_function=search, key="search_key")

st.write(result)

@dividor
Copy link

dividor commented Nov 2, 2024

In case it's related, I am seeing the same as kranthi419. Looking at the sample code above, this works and waits for the user to hit enter ...

result = st_searchbox(search_function=search, key="search_key")

But this executes as soon as the user types ...

result = st_searchbox(search_function=search, key="search_key", default_use_searchterm=True)

My use case needs the user to be able to enter their own search queries, like google.

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

3 participants