two buttons.
one expander in each button.
both expanders are collapsed by default.
expanding one expander under one button automatically leads to another expander expanding.
Am I missing something here or is this a bug?
here’s the live demo
Streamlit
import streamlit as st
b0 = st.button("b0")
b1 = st.button("b1")
if b0:
with st.expander("b0_expander", expanded=False):
st.write("b0_write")
if b1:
with st.expander("b1_expander", expanded=False):
st.write("b1_write")
maybe something related:
I am having some troubles with st.expander. In the example below, if the second expander is opened and then the button is clicked, on the next run, the first expander is opened while the second one is closed. Any idea what is causing that?
import streamlit as st
# Load the data
button = st.button('Click me')
# Display message
container = st.container()
if button:
with container:
st.markdown('Data loaded')
# Expanders
with st.expander('Expander 1'):
st.markdown('Expander 1X')
…
clearing cache doesn’t help
opened 10:56AM - 21 Nov 19 UTC
closed 02:02PM - 04 Dec 19 UTC
I would like to create a button to manually free the cache, e.g. at the end of p… rocessing all frames.
This option will help me to create a workaround to the conflict that occurs when caching cap object (from cv.VideoCapture) and cap.release()
Hey @kimehta ,
First, welcome to the Stereamlit community!
Thanks so much for your detailed explanation and especially for the super helpful app and the exact steps to reproduce what you’re seeing. The same thing happens when I try and I have sent this onto the team to check out!
I will let you know once I hear more from them!
Happy Streamlit-ing!
Marisa
Hey @kimehta ,
The team was able to reproduce this and we have created an issue that you can follow on GitHub as we fix this bug!
opened 07:18PM - 10 Jan 22 UTC
bug
confirmed 🤝
P2 ⛈
### Summary
The expanded/collapsed state of two distinct expanders seems to b… e incorrectly shared. Consider the code snippet and repro steps below.
### Steps to reproduce
```python
import streamlit as st
b0 = st.button("b0")
b1 = st.button("b1")
if b0:
with st.expander("b0_expander", expanded=False):
st.write("b0_write")
if b1:
with st.expander("b1_expander", expanded=False):
st.write("b1_write")
```
1. click b0 & b1 and observe that both b0_expander & b1_expander are collapsed
2. click b0 & expand b0_expander
3. click b1
4. b1_expander should be collapsed but is expanded.
**Expected behavior:**
`b1` should be collapsed as it is a newly drawn expander distinct from `b0`
**Actual behavior:**
`b1` inherits the expanded state from `b0` on initial render
### Is this a regression?
unsure, but probably not?
### Debug info
- Streamlit version: 1.3.1
- Python version: 3.8.9
- OS version: MacOS 12.1
- Browser version: Chrome v96
### Additional information
This issue was originally reported [in this post](https://discuss.streamlit.io/t/expander-expanded-false-not-working/20786) on the forum. An app demonstrating the bug [can be found here](https://share.streamlit.io/kimehta/octopus-streamlit/main/temp.py)
Happy Streamlit-ing!
Marisa
system
Closed
January 11, 2023, 5:16pm
4
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.