Skip to content

Reflex 0.9: self.router.url.query not refreshed when URL is updated with window.history.replaceState #6603

Description

@TianyiLi10

Describe the bug
I have a select filter that updates the URL query parameters whenever the selected filter value changes. The URL is updated using rx.call_script with window.history.replaceState.

Before upgrading to Reflex 0.9, updating the URL this way would also update the route query values accessible through self.router.url.query.

After upgrading to Reflex 0.9, the browser URL changes correctly, but self.router.url.query no longer reflects the updated query parameters.

I run with reflex run --env prod

To Reproduce
Steps to reproduce the behavior:

  1. Create a select filter component, for instance with query parameter: name.
  2. On filter change, update the URL query parameters using:
    rx.call_script(
    "window.history.replaceState({}, '', '?name=test')"
    )
  3. Read the current query parameters from: self.router.url.query
  4. Observe that after the URL is updated, self.router.url.query still contains the old values.
  • Code/Link to Repo:

Expected behavior
When the URL query parameters are modified via window.history.replaceState, the router state should stay in sync and self.router.url.query should reflect the updated query parameters.

Screenshots
If applicable, add screenshots to help explain your problem.

Specifics (please complete the following information):

  • Python Version: 3.11
  • Reflex Version: 0.9.4
  • OS: Linux
  • Browser (Optional): Chrome

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions