Commit ad02257c authored by Clement Ho's avatar Clement Ho

Fix bug where clear search button would not toggle visible

parent d797b03b
......@@ -32,6 +32,7 @@
const clearSearch = document.querySelector('.clear-search');
input.addEventListener('input', this.tokenize.bind(this));
input.addEventListener('input', this.toggleClearSearchButton);
input.addEventListener('keydown', this.checkForEnter.bind(this));
clearSearch.addEventListener('click', this.clearSearch.bind(this));
......@@ -42,10 +43,8 @@
event.preventDefault();
this.clearTokens();
const input = document.querySelector('.filtered-search');
input.value = '';
event.target.classList.add('hidden');
document.querySelector('.filtered-search').value = '';
document.querySelector('.clear-search').classList.add('hidden');
}
clearTokens() {
......@@ -101,13 +100,20 @@
}
}
toggleClearSearchButton(event) {
const clearSearch = document.querySelector('.clear-search');
if (event.target.value) {
clearSearch.classList.remove('hidden');
} else {
clearSearch.classList.add('hidden');
}
}
tokenize(event) {
// Re-calculate tokens
this.clearTokens();
// Enable clear button
document.querySelector('.clear-search').classList.remove('hidden');
const input = event.target.value;
const inputs = input.split(' ');
let searchTerms = '';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment