fixed issue where search suggestions happened twice, causing weird behavior

This commit is contained in:
partisan 2024-09-26 19:54:41 +02:00
parent afe420a0ed
commit c094d9e6a1

View file

@ -52,6 +52,7 @@ async function getSuggestions(query) {
let currentIndex = -1; // Keep track of the currently selected suggestion let currentIndex = -1; // Keep track of the currently selected suggestion
// Handle click events on the type buttons
let results = []; let results = [];
searchInput.addEventListener('input', async () => { searchInput.addEventListener('input', async () => {
let input = searchInput.value; let input = searchInput.value;
@ -128,15 +129,6 @@ function renderResults(results) {
resultsWrapper.innerHTML = `<ul>${content}</ul>`; resultsWrapper.innerHTML = `<ul>${content}</ul>`;
} }
// Function to handle search input
searchInput.addEventListener('input', async () => {
let input = searchInput.value;
if (input.length) {
const results = await getSuggestions(input);
renderResults(results);
}
});
// Handle click events on the type buttons // Handle click events on the type buttons
const typeButtons = document.querySelectorAll('[name="t"]'); const typeButtons = document.querySelectorAll('[name="t"]');
typeButtons.forEach(button => { typeButtons.forEach(button => {