Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve URL fragment identifier when updating query params #9664

Open
2 tasks done
benlindsay opened this issue Oct 14, 2024 · 1 comment
Open
2 tasks done

Preserve URL fragment identifier when updating query params #9664

benlindsay opened this issue Oct 14, 2024 · 1 comment
Labels
feature:query-params type:enhancement Requests for feature enhancements or new features

Comments

@benlindsay
Copy link

Checklist

  • I have searched the existing issues for similar feature requests.
  • I added a descriptive title and summary to this issue.

Summary

Currently, updating query parameters via st.query_params removes fragment identifiers, if one is present in the URL. This makes it so that links to the page intended to jump to a subsection of the page will fail to jump to the subsection if query params are modified before that subsection is generated.

Why?

I have an app with multiple sections, and I'd like to send emails out with a link to specific subsections, like myapp.com/?account_id=123#subsection. During generation of the app, before generating the subsections I'd want to link to, the query params get read and modified, which removes the #subsection fragment identifier, so the page doesn't jump to that section once it's generated.

As a minimal example, with this app:

import time
import streamlit as st

st.title("Title")

st.write("Content " * 50)

st.query_params["foo"] = "bar"

time.sleep(1)
st.subheader("Subsection")

st.write("Content " * 500)

Navigating to http://localhost:8501/#subsection does not jump to the subsection because of the query params modification. But if you comment that out, it works just fine.

How?

The change I'm suggesting would likely only be an internal change. I imagine the expected behavior of modifying query params would be preserving the fragment identifier and preserving the ability to jump to the specified id.

Additional Context

Here is a forum question from someone else whose issue would likely be resolved by this change: https://discuss.streamlit.io/t/query-params-anchors/77951/2

@benlindsay benlindsay added the type:enhancement Requests for feature enhancements or new features label Oct 14, 2024
Copy link

To help Streamlit prioritize this feature, react with a 👍 (thumbs up emoji) to the initial post.

Your vote helps us identify which enhancements matter most to our users.

Visits

@jrieke jrieke changed the title Preserve fragment identifier when updating query params Preserve URL fragment identifier when updating query params Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature:query-params type:enhancement Requests for feature enhancements or new features
Projects
None yet
Development

No branches or pull requests

2 participants