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

Skip to content

Page doesn't scroll to anchor link on first load #11551

@sfc-gh-tteixeira

Description

@sfc-gh-tteixeira

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 visiting an app with a URL that has an anchor link (e.g. foo.com/myapp#myanchor) Streamlit should scroll to the anchor #myanchor on the page. This is not happening today.

Reproducible Code Example

import streamlit as st

st.header("My title 1")
for _ in range(30):
    st.text("blah " * 100)

st.header("My title 2")
for _ in range(30):
    st.text("blah " * 100)

Steps To Reproduce

  1. Run the code above
  2. A Streamlit app will load in a browser tab
  3. Open a new browser tab (it has to be a new tab!)
  4. Navigate to the URL http://localhost:8501/#my-title-2

Expected Behavior

The app loads and the viewport is scrolled to "My title 2".

Current Behavior

The app loads but the viewport is at the top, at "My title 1".

Is this a regression?

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

Debug info

  • Streamlit version: 1.45
  • Python version: 3.13
  • Operating System: MacOS
  • Browser: Chrome

Additional Information

No response

Metadata

Metadata

Assignees

Labels

priority:P2Medium-high priority - fix within one monthstatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expectedtype:regressionThis bug is a regression from previous behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions