Form does not render output from the custom component

Hello everyone!
I’ve wrote a custom search box component based on this example: GitHub - m-wrzr/streamlit-searchbox: Streamlit searchbox that dynamically updates and provides a list of suggestions based on a provided function. It takes list from a search-function and render it as an options to chose from in search field.


It works as it should. However, if I put it into the form:

with st.form(“my_form”):
selected_value = custom_searchbox(search_df, key=“test”)
st.markdown(“You’ve selected: %s” % selected_value)
k = st.text_input(“Additional Text Input in the form”)
val = st.form_submit_button(label=“Save”)
if val:
res = {“text input”: k, ‘suffered component’: selected_value}
st.write(res)
search field does not render items:

But logic behind search function definitely works – if push save it does render my list from search-function:


And search box outside the form works as it should and returns stuff from either the search field and form when form is invoked:

selected_value = custom_searchbox(search_df, key=“test”)
with st.form(“my_form”):
st.markdown(“You’ve selected: %s” % selected_value)
k = st.text_input(“Additional Text Input in the form”)
val = st.form_submit_button(label=“Save”)
if val:
res = {“text input”: k, ‘suffered component’: selected_value}
st.write(res)

So my questions is: Why component does not render list inside of form (is it some form innate hinderance? ) And how name scope works considering this components?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.