Preserve URL fragment identifier / anchor when updating query params
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start by tracing the internal handling of st.query_params updates and reproduce the minimal example from the issue with a URL containing #subsection. Done means changing query parameters no longer removes the fragment identifier, so the page still jumps to the requested subsection.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 45.8k
- Forks
- 4.4k
- Avg merge
- 21h 22m
- Merged PRs (30d)
- 316
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from streamlit/streamlit
-
area:backend area:network feature:embedding feature:runtime priority:P3 status:confirmed type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
area:frontend area:security feature:st.file_uploader status:unlikely type:enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
area:backend area:security feature:cache feature:cache-hash-func priority:P4 status:confirmed type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
area:mobile feature:st.camera_input papercut type:enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
area:ai type:enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
All issues in streamlit/streamlit
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100