Skip to content

Commit

Permalink
Fix JS failures
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed Apr 10, 2024
1 parent 541bda8 commit 34afa85
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion assets/js/autocomplete/autocomplete-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function togglePreview () {
export function hidePreview () {
state.previewOpen = false
const suggestionList = qs(AUTOCOMPLETE_SUGGESTION_LIST_SELECTOR)
suggestionList.classList.remove('previewing')
if(suggestionList) { suggestionList.classList.remove('previewing') }

Check failure on line 150 in assets/js/autocomplete/autocomplete-list.js

View workflow job for this annotation

GitHub Actions / Check JS

Expected space(s) after "if"
removePreview()
}

Expand Down
19 changes: 8 additions & 11 deletions assets/js/search-bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,22 +99,19 @@ function addEventListeners () {

searchInput.addEventListener('blur', event => {
const relatedTarget = event.relatedTarget
const suggestionList = qs(AUTOCOMPLETE_SUGGESTION_LIST_SELECTOR)

if (relatedTarget) {
if (relatedTarget && suggestionList && suggestionList.contains(relatedTarget)) {
// If blur is triggered caused by clicking on an autocomplete result,
// then ignore it, because it's handled in the click handler below.
if (qs(AUTOCOMPLETE_SUGGESTION_LIST_SELECTOR).contains(relatedTarget)) {
setTimeout(() => {
// Focus the input after a while, so that it's easier to close
// or get back to after an accidental blur
setTimeout(() => {
if (isAutocompleteListOpen()) {
searchInput.focus()
}
}, 1000)
return null
} else {
hideAutocomplete()
}
if (isAutocompleteListOpen()) {
searchInput.focus()
}
}, 1000)
return null
} else {
hideAutocomplete()
}
Expand Down

Large diffs are not rendered by default.

0 comments on commit 34afa85

Please sign in to comment.