Repository: streamlit/streamlit

Issue:
Right-side label of `st.slider` and `st.select_slider` overflows when inside `st.expander`
### Checklist

- [x] I have searched the [existing issues](https://github.com/streamlit/streamlit/issues) for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.

### Summary

Right-side label of `st.slider` and `st.select_slider` overflows when inside `st.expander`.

In the past I submitted a similar issue for the left-side label (see https://github.com/streamlit/streamlit/issues/5898); now it is the right-side label that is misbehaving.

### Reproducible Code Example

[![Open in Streamlit Cloud](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://issues.streamlitapp.com/?issue=gh-6297)

```Python
import streamlit as st

st.title("Right-side label of slider and select_slider overflows when inside expander")

with st.expander('Example st.expander'):

    single_value = st.slider(
        label='Example st.slider',
        min_value=9_500_000,
        max_value=10_000_000,
        value=10_000_000
    )

    first_value,last_value = st.slider(
        label='Example st.slider (range mode)',
        min_value=9_500_000,
        max_value=10_000_000,
        value=(9_500_000,10_000_000)
    )

    single_value = st.select_slider(
        label='Example st.select_slider',
        options=['Maradona','Ronaldo','Pele','This is a very, very long label'],
        value='This is a very, very long label'
        )

    first_value,last_value = st.select_slider(
        label='Example st.select_slider (range mode)',
        options=['Maradona','Ronaldo','Pele','This is a very, very long label'],
        value=['Maradona','This is a very, very long label']
        )
```


### Steps To Reproduce

1. Run the reproducible code example
2. Open the expander and see that all the right side labels are overflowing

### Expected Behavior

Labels should not overflow beyond the widgets width.

### Current Behavior

_No response_

### Is this a regression?

- [X] Yes, this used to work in a previous version.

### Debug info

- Streamlit version: 1.20.0
- Python version: 3.11
- Operating System: macOS
- Browser: Brave
- Virtual environment: conda

### Additional Information

_No response_

### Are you willing to submit a PR?

- [ ] Yes, I am willing to submit a PR!


Discussion:
@marduk2 Thanks for reporting this issue. I was able to reproduce it [here](https://issues.streamlit.app/?issue=gh-6297). It seems to happen after the second expansion:

<img width="896" alt="image" src="https://user-images.githubusercontent.com/2852129/225903036-da9b82eb-e39b-4ca7-9c3d-aa86bd23dff4.png">


Resolving patch:
diff --git a/e2e/scripts/st_select_slider.py b/e2e/scripts/st_select_slider.py
--- a/e2e/scripts/st_select_slider.py
+++ b/e2e/scripts/st_select_slider.py
@@ -88,3 +88,12 @@ def on_change():
     )
     st.write("Value 8:", st.session_state.select_slider8)
     st.write("Select slider changed:", "select_slider_changed" in st.session_state)
+
+with st.expander("Expander", expanded=True):
+    w9 = st.select_slider(
+        label="Label 9",
+        options=["foo", "bar", "baz", "This is a very, very long option"],
+        value="This is a very, very long option",
+    )
+
+    st.write("Value 9:", w9)


Test patch: