Fix incorrect links in search suggestions

This commit is contained in:
partisan 2024-11-16 12:34:40 +01:00
parent 2741c2ff3d
commit 0d083f53e7
7 changed files with 13 additions and 3 deletions

View file

@ -101,9 +101,13 @@ document.addEventListener('DOMContentLoaded', () => {
searchInput.value = query;
resultsWrapper.innerHTML = '';
searchWrapper.classList.remove('wrapper-searching');
const form = searchInput.closest('form');
form ? form.submit() : window.location.href = `/search?q=${encodeURIComponent(query)}&t=web`;
}
// Retrieve the `t` parameter from the hidden input or set a default
const currentTemplateType = document.querySelector('input[name="t"]').value || 'web';
// Redirect to the appropriate results page
window.location.href = `/search?q=${encodeURIComponent(query)}&t=${encodeURIComponent(currentTemplateType)}`;
}
// Handle clicks on search suggestions
resultsWrapper.addEventListener('click', (event) => {