Two searchboxes are not working
Closed this issue · 4 comments
I try to use two searchboxes for searches on one wikibase instance (one for items, one for properties), but the second one becomes unusable as soon as the first one is updated (Error: Attempt to use history.pushState() more than 100 times per 30 seconds). If I only use the second one, it works fine. I renamed all functions and variables with no effect.
Can you provide an example? The searchbox should support multiple components if separate keys
are provided.
Hi thanks for sharing this work, but I have the same issue.
- 1. This is how I created the functions:
def location_input(string):
params = {
'input': string,
'key': api_key
}
response = requests.get(base_url, params=params)
predictions = response.json()['predictions']
return [prediction['description'] for prediction in predictions]
SEARCHBOX Component: Pass location_input to searchbox feature in streamlit list format
def search_location_A(searchterm, rerun=False) -> List[str]:
return location_input(searchterm) if searchterm else []
def search_location_B(searchterm, rerun=False) -> List[str]:
return location_input(searchterm) if searchterm else []
- this is how I am calling the function in streamlit
Add a label above the searchbox
st.write("Starting Point A:")
pass search function to searchbox
selected_location_A = st_searchbox(
search_location_A, # test in the streamlit frontend>> 'Nordhauser Straße' >> select: address_1 = 'Nordhauser Straße 2, 10589 Berlin, Deutschland'
key="location_searchbox_A",
)
---------------Location Input 2------
Add a label above the searchbox
st.write("Starting Point B:")
pass search function to searchbox
if selected_location_A:
selected_location_B = st_searchbox(
search_location_B, # test in the streamlit frontend>> 'Rudi-Dutschke' >> select: address_2 = 'Rudi-Dutschke-Straße 26, 10969 Berlin'
key="location_searchbox_B",
)
The first searchbox works fine, the second gives no option.
But if I start selecting a location from the second location and then I move to the first one everything works.
@raffaeletrigg Thank you for the example!
Can you check if upgrading to version 0.1
fixes this issue for you? At least for me the example above now works as expected - previously there wasn't proper support for multiple searchboxes..
Thank you very much for your feedback, I will try it again with the new version! Besides that issue, it works fantastic!