Skip to content

Cannot fully clear query params with pushState #13827

Description

@andykais

Describe the problem

I am using query params on a search page to store things like ?tags=foo,bar and when the user inputs an "empty" search (e.g. no tags filter), I want to clear away all the query params on the page. The problem is, pushState treats pushState('', {}) as a special call that does not update the route. The best I can do is pushState('?', {}) which leaves an ugly question mark in my url like so: /browse?.

Describe the proposed solution

What I would like is a way to fully clear away query params and the lingering ? character. I'm thinking this can either be the default behavior of pushState('?', {}) or it could be a special flag added like pushState('', {clearQueryParams: true})

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions