tabs switching cause scrolling up
See original GitHub issueSummary
app scrolls up when I have tabs after some widgets and switch them
Steps to reproduce
Code snippet:
import streamlit as st
for i in range(20):
st.markdown("dummy text")
tab1, tab2 = st.tabs(["tab1", "tab2"])
with tab1:
st.video(video_path)
with tab2:
st.video(video_path)
steps :
- scroll down to the videos
- switching tabs
Expected behavior:
tabs should be switched and focus stay on video
Actual behavior:
it scrolling up and I have to scroll down again
Debug info
- Streamlit version: 1.11.0
- Python version: 3.8.11
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Clicking JS Tabs Causes Browser to Scroll Up - Stack Overflow
It only happens if you scroll down so the video is above the bottom of your browser. It seems to be a problem...
Read more >Uncontrollable Scrolling - Microsoft Community
Anywhere in the settings app, if the page can be scrolled down it will scroll down to the bottom even after resizing the...
Read more >Allow switching tabs by scrolling in the tab bar when it doesn't ...
Firefox uses the mouse wheel in the tabbar to scroll the tabs when they are overflowing. We won't be able to change tabs...
Read more >How to prevent switching tabs using horizontal mouse scroll in ...
According to this thread the Chromium development team fixed the issue in late August 2019 and it was included in Release 77 of...
Read more >Fix Infinite/Automatic Scrolling On Windows 10/11 PC - YouTube
How to Fix Automatic/Infinite Scrolling On Windows 11/10 PC,Windows 10/11 ... Windows 10/11 mouse scrolling automatically up or down,Mouse ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@RRaphaell Thanks for reporting this issue! I was able to reproduce it and have deployed a demo app here. The underlying issue is that when changing tabs, the height of the actual tab content is not correct for a split second. This influences the full height of the app -> which in turn influences the maximum possible scroll position -> and this causes the unexpected up scroll. This does not happen if there is enough content underneath the tab (try out in the demo app), since in that case the scroll position will not be larger than the maximum possible.
To find a solution here requires a bit more investigation. I tried out the
renderAll
property of the baseWeb component, but this only fixes it for a second tab change.@sfc-gh-tszerszen Thanks for investigating this! I think there are also a few other elements without a fixed height. For example, our built-in chart commands:
So, we might need to figure out which elements are affected and apply the same fix.
Would be great if we can fix it this way, but this needs some testing if there are any negative side effects. E.g. in some situations, components are reused for different content, so just fixing the height on
componentDidMount
might lead to wrong height in some situations.