Reloading issues with selection in buttons or checkboxes

hi! We’re having some trouble with buttons in tabs. Anytime a user clicks a button outside of a form, the page refreshes itself instead of executing the code. Here’s a paraphrased version of the code:

with tab1:
  with st.form("test"):
    ...
  if st.button("click"):
    st.write("print")

While the form submission works fine, the button outside of the form reloads the page. Any ideas?

Hey @faisal.lalani, thanks for reporting this issue. Your issue might be related to a race condition we had with Streamlit version 1.9 & 1.10 that sometimes leads to the widget state being dropped and the page being refreshed. We fixed it in 1.11 (see this PR ). Is your app running with Streamlit 1.11?

Yep! I think you need 1.11 anyway to use tabs, but I double checked anyway and I am using that version.

that’s true :sweat_smile: In that case, this is unrelated and probably a new unknown issue. Unfortunately, I’m not able to reproduce it with the following code (deployed app):

import streamlit as st

tab1, tab2, tab3 = st.tabs(["tab1", "tab2", "tab3"])
with tab1:
    with st.form("test"):
        st.number_input("test")
        st.form_submit_button("submit")
    if st.button("click"):
        st.write("print")

Do you have any code example that reproduces the issue?

Hi @lukasmasuch
the issue could be reproduced as and when we use the result of submit button. for example

    submitted = False
    with st.form("test"):
        st.number_input("test")
        submitted = st.form_submit_button("submit")
    if submitted:
        # df = st.experimental_data_editor([2,2,3])
        # st.write(df)
        if st.button("click"):
            st.write(df)

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