-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
Good Afternoon,
Thank you for this powerful library π .
I have noticed a small bug with st.file_uploader : regardless of whether disabled is True or False, it is always possible to remove files in the GUI.
As a result, this will trigger an app rerun.
Below a piece of code to reproduce the issue.
Reproducible Code Example
import streamlit as st
st.session_state["disable"] = st.session_state.get("disable", False)
st.session_state["counter"] = st.session_state.get("counter", 0) + 1
st.info(f"Script rerun {st.session_state["counter"]} times")
files = st.file_uploader(label = "", disabled = st.session_state["disable"])
st.info(f"File uploaded: {files is not None}")
button = st.button("Enable" if st.session_state["disable"] else "Disable")
if button:
st.session_state["disable"] = not st.session_state["disable"]
st.rerun()Steps To Reproduce
- Run the app
- Upload any file
- Click on the "Disable" button
At this point, notice how you can't click the file_uplaoder to change the file.
Also note what the number of reruns is.
Finally, notice how the script can indeed see a file was uploaded (as shown in st.info)
- Click on the X at the right of the uploaded filename
At this point, notice how you still can't click the file_uplaoder to change the file (which if good).
Also note that the number of reruns has increased (this is not good).
Finally, notice how the script can detect file_uploader no longer storing a file.
Expected Behavior
I would expect disabled parameter of st.file_uploader to both:
- Not allow to replace the uploaded file(s) --> current behaviour
- Not allow to remove any previously uploaded file(s) --> improvement
Current Behavior
Explained in the steps to reproduce
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.47.0
- Python version: 3.13.2
- Operating System: Windows 11 Enterprise 23H2
- Browser: Edge
Additional Information
No response