Merge pull request #17 from Serraniel/feature/#12-search-input-with-hotkey

#12 Fixed issue that last dropdown will pop in wrong position
This commit is contained in:
Daniel 2020-08-04 11:23:57 +02:00 committed by GitHub
commit 9817ab3828
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,6 +33,9 @@ function initSearch() {
// register focus hotkey // register focus hotkey
document.addEventListener('keypress', event => handleSearchForShiftF(event)); document.addEventListener('keypress', event => handleSearchForShiftF(event));
// additionally, the last dropdown ul has a "right: 0px" style, which has to be fixed with auto, otherwhise it will pop up in the wrong position
Array.from(menu.querySelectorAll('ul.dropdown')).slice(-1)[0].style.right = 'auto';
} }
function handleQuickSearch(event) { function handleQuickSearch(event) {
@ -44,6 +47,7 @@ function handleQuickSearch(event) {
url.pathname = '/search'; url.pathname = '/search';
url.searchParams.append('q', quickSearchElement.value); url.searchParams.append('q', quickSearchElement.value);
// clicking the link; we are not setting window.location because this will trigger a complete reload of the site
linkElement.href = `${url.pathname}${url.search}`; linkElement.href = `${url.pathname}${url.search}`;
linkElement.click(); linkElement.click();