Component should not have a submit button
RusabKhan opened this issue · 2 comments
The submit button should be toggleable so that we can remove it and have st.button submit button. It should behave like the default streamlit textbox and on an external submit it should fetch the text value.
Normal streamlit behaviour:
text = st.text_input('my input')
submit = st.button('submit')
if submit:
st.write(text)
with streamlit-ace
val = st_ace('input json', height=350,
language='json', theme='twilight', wrap=True, auto_update=False)
if val:
st.write(val) # this will always write on startup since we have given a default value.
Hei! If you set auto_update=True, it will work as in your first example and the APPLY button will not be shown.
UPD: Although... with auto_update=True, the entire page is restarted whenever the text in the editor changes. I agree, this is not very good. You need to be able to get the contents of the editor when auto_update=False without the Apply button.
@RusabKhan So. I found a way to get the desired behavior by putting st_ace inside st.form. This allows you to refuse to Apply (auto_update=True impact), but at the same time not to reload the entire page (st.form impact). Try this:
with st.form('Code'):
val = st_ace('input json', height=350,
language='json', theme='twilight', wrap=True, auto_update=True)
submitted = st.form_submit_button("Submit")
if submitted:
if val:
st.write(val)