mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-19 18:42:34 +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', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const algoliaSettings = CONFIG.algolia;
|
const algoliaSettings = CONFIG.algolia;
|
||||||
const { indexName, appID, apiKey } = algoliaSettings;
|
const { indexName, appID, apiKey } = algoliaSettings;
|
||||||
const input = document.querySelector('.search-input');
|
|
||||||
|
|
||||||
let search = instantsearch({
|
let search = instantsearch({
|
||||||
indexName,
|
indexName,
|
||||||
searchClient : algoliasearch(appID, apiKey),
|
searchClient : algoliasearch(appID, apiKey),
|
||||||
searchFunction: helper => {
|
searchFunction: helper => {
|
||||||
if (input.value) {
|
if (document.querySelector('.search-input').value) {
|
||||||
helper.search();
|
helper.search();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
document.querySelectorAll('.popup-trigger').forEach(element => {
|
document.querySelectorAll('.popup-trigger').forEach(element => {
|
||||||
element.addEventListener('click', () => {
|
element.addEventListener('click', () => {
|
||||||
document.body.classList.add('search-active');
|
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