search click bug fix

This commit is contained in:
zzossig 2020-02-08 22:52:58 +09:00
parent 556770af2e
commit d7c9185329
1 changed files with 18 additions and 5 deletions

View File

@ -844,11 +844,12 @@
var searchElem = document.getElementById('search'); var searchElem = document.getElementById('search');
var searchMobile = document.getElementById('search-mobile'); var searchMobile = document.getElementById('search-mobile');
var searchResults = document.getElementById('search-results');
searchElem ? searchElem ?
searchElem.addEventListener('input', function(e) { searchElem.addEventListener('input', function(e) {
if (!e.target.value | window.innerWidth < 770) { if (!e.target.value | window.innerWidth < 770) {
document.getElementById('search-results').setAttribute('class', 'dropdown'); searchResults ? searchResults.setAttribute('class', 'dropdown') : null;
searchResult ? searchResult.setAttribute('data-display', 'none') : null; searchResult ? searchResult.setAttribute('data-display', 'none') : null;
summaryContainer ? summaryContainer.setAttribute('data-display', 'block') : null; summaryContainer ? summaryContainer.setAttribute('data-display', 'block') : null;
return null; return null;
@ -869,6 +870,13 @@
} else { } else {
renderSearchResultsSide(searchText, results); renderSearchResultsSide(searchText, results);
} }
var dropdownItems = searchResults.querySelectorAll('.dropdown-item');
dropdownItems ? dropdownItems.forEach(function(item) {
item.addEventListener('mousedown', function(e) {
e.target.click();
});
}) : null;
} }
}) : null; }) : null;
@ -877,9 +885,7 @@
if (window.innerWidth < 770) { if (window.innerWidth < 770) {
return null; return null;
} }
setTimeout(function () { searchResults ? searchResults.setAttribute('class', 'dropdown') : null;
document.getElementById('search-results').setAttribute('class', 'dropdown');
}, 100);
}) : null; }) : null;
searchElem ? searchElem ?
@ -888,7 +894,7 @@
return null; return null;
} }
if (!e.target.value) { if (!e.target.value) {
document.getElementById('search-results').setAttribute('class', 'dropdown'); searchResults ? searchResults.setAttribute('class', 'dropdown') : null;
return null; return null;
} }
@ -907,6 +913,13 @@
} else { } else {
renderSearchResultsSide(searchText, results); renderSearchResultsSide(searchText, results);
} }
var dropdownItems = searchResults.querySelectorAll('.dropdown-item');
dropdownItems ? dropdownItems.forEach(function (item) {
item.addEventListener('mousedown', function (e) {
e.target.click();
});
}) : null;
} }
}) : null; }) : null;