Skip to content

Commit

Permalink
Merge pull request #762 from maykinmedia/fix/1739-fix-infinite-loop-s…
Browse files Browse the repository at this point in the history
…earch-filters

[#1739] 🐛 Fix infinite loop for search page filters
  • Loading branch information
alextreme authored Sep 17, 2023
2 parents 0a4b263 + b62d4c5 commit 8adfa7e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/open_inwoner/js/components/search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ const radioButtons = document.querySelectorAll(
})
})

var timerId = 0
let timerId = null

const searchForm = document.getElementById('search-form')

const filterButtons = document.querySelectorAll('.filter .checkbox__input')
;[...filterButtons].forEach((checkbox) => {
checkbox.addEventListener('change', (event) => {
clearInterval(timerId)
timerId = setInterval(() => {
clearTimeout(timerId)

// Set a new timeout
timerId = setTimeout(() => {
searchForm.submit()
}, 250)
})
Expand Down

0 comments on commit 8adfa7e

Please sign in to comment.