Skip to content

Commit

Permalink
Merge pull request #590 from vtex-apps/feature/fix-clear-filter
Browse files Browse the repository at this point in the history
fix clear filter behavior when the filter is not applied yet
  • Loading branch information
hiagolcm authored Jun 21, 2022
2 parents 0143b5f + a001653 commit 20de62d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed
- Clear filter behavior when the filter is not applied yet.

## [3.117.4] - 2022-06-08

### Fixed
Expand Down
5 changes: 5 additions & 0 deletions react/components/FilterSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ const FilterSidebar = ({
(!key || (key && key === facet.key))
)

if (selectedFacets.length === 0 && key) {
setFilterOperations(filterOperations.filter(filter => filter.key !== key))
return
}

// Should not clear categories, departments and clusterIds
const selectedRest = filterOperations.filter((facet) =>
isCategoryDepartmentCollectionOrFT(facet.key)
Expand Down

0 comments on commit 20de62d

Please sign in to comment.