Skip to content

Commit

Permalink
Clear search box red color in more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
haukex committed Aug 17, 2024
1 parent 69013b7 commit cd8ebdd
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/js/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ window.addEventListener('DOMContentLoaded', async () => {
closeAllPopups()
}

// in doSearch below, we highlight the search term red for one character searches.
// any user input in the field clears that:
search_term.addEventListener('input', () => search_term.classList.remove('danger') )

// this is our handler for running the search:
const doSearch = (what: string) => {
// NOTE we expect our callers to have done cleanSearchTerm(what)
Expand Down Expand Up @@ -269,8 +273,11 @@ window.addEventListener('DOMContentLoaded', async () => {
// search term keyboard handler
search_term.addEventListener('keyup', event => {
// Escape key clears input
if (event.key=='Escape')
if (event.key=='Escape') {
search_term.value = ''
search_term.classList.remove('danger')
}
// Enter key triggers search
else if (event.key=='Enter') {
event.preventDefault()
event.stopPropagation()
Expand Down

0 comments on commit cd8ebdd

Please sign in to comment.