Skip to content

Commit

Permalink
Highlight the filter if there are selected options
Browse files Browse the repository at this point in the history
  • Loading branch information
rainerdema committed Sep 21, 2023
1 parent dcf0b25 commit 8991b30
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default class extends Controller {

connect() {
this.setCheckboxesFromUrlParams()
this.highlightFilter()
useClickOutside(this)
}

Expand Down Expand Up @@ -59,4 +60,12 @@ export default class extends Controller {
container.appendChild(checkbox.closest('div'))
})
}

highlightFilter() {
const optionIsSelected = this.optionTargets.some((option) => {
return option.querySelector("input[type=checkbox]").checked
})

this.summaryTarget.classList.toggle("bg-gray-100", optionIsSelected)
}
}

0 comments on commit 8991b30

Please sign in to comment.