Skip to content

[Refactor] searchStore URL sync uses replaceState directly — breaks browser history #777

Description

@RUKAYAT-CODER

Overview

src/app/store/searchStore.ts calls window.history.replaceState whenever search filters change. replaceState overwrites the current history entry without creating a new one, so the Back button cannot navigate to a previous search query. Users who want to go back to their previous search state are forced to manually re-enter all their filters.

Specifications

Features:

  • Each distinct search query creates a history entry so the Back button restores the previous search
  • URL reflects current filter state and is shareable

Tasks:

  • Replace replaceState with pushState for significant filter changes (new search query, changed category)
  • Retain replaceState for minor transient changes such as pagination cursor updates
  • Implement a popstate event listener to restore filter state when navigating Back
  • Add tests asserting that pushState is called on a new search query

Impacted Files:

  • src/app/store/searchStore.ts

Acceptance Criteria

  • Navigating Back after a search returns to the previous query with all filters restored
  • URL accurately reflects current filter state
  • replaceState is only used for pagination or cursor updates, not query changes

Metadata

Metadata

Assignees

No one assigned

    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