Skip to content

Reset filters to initial state on setSearchTerm #619

@marcvangend

Description

@marcvangend

When a search term is set, the filters are cleared by default. This usually makes sense and most search interfaces on the web behave the same. However, in a setup where initialState is used, I would expect that setSearchTerm restores the initial filters, similar to what reset does.

My personal use-case is a site with multilingual content. The search results are initially filtered by the active site language, but users can change the language filter to show other languages too. Currently, the setSearchTerm action clears the language filter. Instead, I need (and expected) Search UI to restore the initial language filter.

Proposed solution
Either of these two options:

  1. Change the behavior of the shouldClearFilters option to restore initial filters if there are any.
  2. Add a new option to setSearchTerm, eg. shouldResetFilters, to reset filters to the initial state.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions