Skip to content

Commit

Permalink
Fix null value of .search-input selector
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Jul 11, 2020
1 parent 46b4ad9 commit dca900a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions source/js/algolia-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
document.addEventListener('DOMContentLoaded', () => {
const algoliaSettings = CONFIG.algolia;
const { indexName, appID, apiKey } = algoliaSettings;
const input = document.querySelector('.search-input');

let search = instantsearch({
indexName,
searchClient : algoliasearch(appID, apiKey),
searchFunction: helper => {
if (input.value) {
if (document.querySelector('.search-input').value) {
helper.search();
}
}
Expand Down Expand Up @@ -98,7 +97,7 @@ document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.popup-trigger').forEach(element => {
element.addEventListener('click', () => {
document.body.classList.add('search-active');
setTimeout(() => input.focus(), 500);
setTimeout(() => document.querySelector('.search-input').focus(), 500);
});
});

Expand Down

0 comments on commit dca900a

Please sign in to comment.