Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The sidebar state resets on screen resize #12016

@sfc-gh-dmatthews

Description

@sfc-gh-dmatthews

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

When zooming in or out (Cmd +/Cmd -), the sidebar resets to its initial state. If there is no st.set_page_config, then the sidebar always reopens on zoom. If there is st.set_page_config(initial_sidebar_state="collapsed"), the the sidebar always collapses on zoom.

Reproducible Code Example

import streamlit as st
import pandas as pd

# st.set_page_config(initial_sidebar_state="collapsed")
st.title('Guess who?')

st.text_input('First name')
st.text_input('Last name')

st.sidebar.selectbox('Select a demo', ['','A','B'])

Steps To Reproduce

  1. Run the app.
  2. Close the sidebar
  3. Zoom in, or resize the window. (Sidebar reopens)

Expected Behavior

Zooming in or out shouldn't change the state of elements (except maybe some edge case where the change in zoom changes some boundary condition).

Current Behavior

The sidebar resets to its initial state on zoom and more generally on any resize event.

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version: 1.47.0
  • Python version: 3.13
  • Operating System: Mac
  • Browser: Prisma

Additional Information

I was testing an old issue (#6916) to see if it had resolved with all the sidebar/theming/navigation changes, but I can't carry out the steps to reproduce the old bug because the sidebar resets its state when zooming in or out.

Metadata

Metadata

Assignees

Labels

feature:st.sidebarRelated to `st.sidebar` containerpriority:P1High priority - fix within two weeksstatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions