Skip to content

Commit

Permalink
Tweak filter logic
Browse files Browse the repository at this point in the history
  • Loading branch information
katamartin committed Feb 3, 2025
1 parent 7695c1a commit 4bff6cd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion components/project-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,25 @@ const ProjectType = () => {
} else {
setSelectOthers(Other ? false : updatedSelectOthers)
setProjectType((prev) => {
// If selecting all after having previously filtered, clear filters
if (
All &&
prev &&
prev.length !== projectTypes.Top.length + projectTypes.Other.length
) {
// Handle selecting All:
// - Clear filters by setting projectType to null
// - Ensure Other-filtering is hidden
setSelectOthers(false)
return null
} else if (
!All &&
(!prev ||
prev.length ===
projectTypes.Top.length + projectTypes.Other.length)
) {
// Handle deselecting All:
// - Clear all selections
return []
} else {
const topValues = Object.keys(values).filter((key) => values[key])
let otherValues = []
Expand Down

0 comments on commit 4bff6cd

Please sign in to comment.