Skip to content

Commit

Permalink
Add filter count to filter button (#1367)
Browse files Browse the repository at this point in the history
* Add filter count to filter button

* Fix date filter bug
  • Loading branch information
Kevin Haube authored Sep 26, 2023
1 parent 10a227a commit e2f579e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion services/ui-src/src/components/SearchAndFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,11 @@ function FilterPane<V extends {}>({
setAllFilters,
}: FilterPaneProps<V>) {
const [showFilters, toggleShowFilters] = useToggle(false);
const { state: filterChips } = useFilterChipContext();
const filterCount = useMemo(
() => filterChips.filter((chipVal) => chipVal.label !== null).length,
[filterChips]
);
const { dispatch: updateFilterChips } = useFilterChipContext();
const onResetFilters = useCallback(() => {
// Resets filter chips state to no chips showing
Expand Down Expand Up @@ -524,7 +529,7 @@ function FilterPane<V extends {}>({

return (
<>
<Button onClick={toggleShowFilters}>Filter</Button>
<Button onClick={toggleShowFilters}>Filter ({filterCount})</Button>

{transitionFilterPane((style, showFilters) =>
showFilters
Expand Down

0 comments on commit e2f579e

Please sign in to comment.