Prepopulate Input Using Session State

You definetely have to give your widgets a key value to avoid such issues. I am not 100% sure if this is the same case, however I had a similar question a couple months ago: Make a widget remember its value after it is hidden and shown again in later script runs - #3 by Wally

This is how I am doing it in all of my apps on streamlit 1.11.0 currently.