Baloons is invoked each time i return to tab

I am running Streamlit locally.
streamlit version - 1.27.2
python version - 3.8.8

I have 2 tabs, and in the main tab after i click once the submit button (where st.baloons is trigerred in the end)
each time that i switch between the second tab to this tab back - the baloons are trigerred again.
Can you please assist?
Thanks!

hi @beast1985
could you provide us with your code

the issue might be because of rerun

hi,
i was able to reproduce this issue- with the following code (cleaned up my logic)
Press Submit in task1 tab, then move to task2 tab, and return to task1 tab and you’ll see baloons right away.

thanks!


def create_tabs():

    return st.tabs(['Task1', 'Task2'])


def handle_task1():

    submit_sessions()



def submit_sessions():
    if 'submitted' not in st.session_state:
        st.session_state['submitted'] = False

    if st.button('Submit'):
        # Set the flag when the button is pressed
        st.session_state['submitted'] = True

    if st.session_state['submitted']:
        # Perform the actions upon submission
        with st.spinner('Processing...'):
            st.balloons()
        # Reset the flag immediately after processing
        st.session_state['submitted'] = False


def handle_task2():
    print('handle_task2')


task1, task2 = create_tabs()

with task1:
    handle_task1()

with task2:
    handle_task2()