Skip to content

Commit

Permalink
🐛 Fix the search bar cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard-IMBERT committed May 8, 2018
1 parent 077f2d9 commit 1b5c775
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/front/front.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,24 @@ function drawMap(m) {
// The search bar
inputSearch.addEventListener('change', (e) => {

// storing the search value in case we reload th survivors
const searchValue = e.target.value.toLowerCase()

const search = () => cards.forEach((element) => {
if(!element.cardObject.data.Name
.toLowerCase()
.match(new RegExp(e.target.value.toLowerCase()))
.match(new RegExp(searchValue))
) {
element.card.hidden = true
} else {
element.card.hidden = false
}
})

if(cards.length <= 0) getSurvivors().then(search)
if(cards.length <= 0) getSurvivors().then(() => {
e.target.value = searchValue
search()
})
else search()

})
Expand Down

0 comments on commit 1b5c775

Please sign in to comment.