Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

@lukasmasuch lukasmasuch commented Nov 25, 2025

Describe your changes

Fixes an issue where query parameters don't get synced correctly on browser back navigation.

GitHub Issue Link (if applicable)

Testing Plan

  • Added unit & e2e tests.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Nov 25, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 25, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-13129/streamlit-1.51.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-13129.streamlit.app (☁️ Deploy here if not accessible)

@lukasmasuch lukasmasuch changed the title Fix query parameters not preserved on back navigation [WIP] Fix query parameters not preserved on back navigation Nov 25, 2025
@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users change:bugfix PR contains bug fix implementation and removed change:feature PR contains new feature or enhancement implementation labels Nov 25, 2025
@lukasmasuch lukasmasuch marked this pull request as ready for review November 25, 2025 23:55
Copilot AI review requested due to automatic review settings November 25, 2025 23:55
@lukasmasuch lukasmasuch changed the title [WIP] Fix query parameters not preserved on back navigation Fix query parameters not preserved on back navigation Nov 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where query parameters are not preserved when users navigate back using the browser's back button in multi-page apps. The fix adds a preserveQueryParams parameter that is set to true during browser history navigation to prevent query params from being cleared.

Key Changes:

  • Modified onPageChange to accept an optional preserveQueryParams parameter
  • Updated sendRerunBackMsg to conditionally skip clearing query params when preserveQueryParams is true
  • Added browser back navigation handling to preserve query params from the URL

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
frontend/app/src/App.tsx Added preserveQueryParams parameter to onPageChange and sendRerunBackMsg methods; modified logic to skip clearing query params during history navigation
frontend/app/src/App.test.tsx Added unit test to verify query params are preserved in rerun message after browser back button navigation
e2e_playwright/multipage_apps_v2/mpa_v2_basics_test.py Added e2e test to verify query params are displayed correctly after browser back navigation

Copy link
Collaborator

@sfc-gh-lwilby sfc-gh-lwilby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lukasmasuch lukasmasuch merged commit 3159a72 into develop Nov 26, 2025
43 checks passed
@lukasmasuch lukasmasuch deleted the fix/query-params-not-preserved-on-back-navigation branch November 26, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query Params not preserved on first script run after using the browser "back" button to back to a previous page.

3 participants