mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
Fix null value of .search-input selector
This commit is contained in:
parent
46b4ad92b3
commit
dca900aa7a
@ -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();
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user