Hello everyone,
I’m experiencing intermittent rendering issues with a dynamic form in my Streamlit app, running on the latest version (1.34.0). The form is supposed to display a series of questions with radio buttons and conditional text inputs. However, sometimes it only renders partially, such as only showing the last question (Q16), half of the form, or sometimes none at all, after selecting the “Not Applicable” option and entering text multiple times. This issue occurs both locally and on a sandbox.
Here is the simplified code snippet: Please feel free to copy it and test it in the sandbox or run it locally by saving it as the App.py file.
import streamlit as st
@st.experimental_fragment
def load_survey():
for i in range(16):
answer = st.radio(label=f"Q{i+1}", options=["Yes", "No", "Not Applicable"], horizontal=True, key=f"{1}_{i}")
if answer == "Not Applicable":
res = st.text_input("Please add your reasoning for selecting not applicable", value='', key=f"{1}_{i}_text")
load_survey()
Observed Behavior after clicking several Not applicable and answer explanations:
- Randomly, only Q16 is rendered.
- Sometimes only half of the form appears from the question that you answered last
- Occasionally, no form appears at all after several interactions.
Could anyone please help identify why these rendering inconsistencies are occurring and suggest any potential fixes? Thank you in advance!