scrolling when using the arrows to navigate the prompt list in the shortcut panel

This commit is contained in:
mic 2024-09-14 22:25:08 +02:00
parent 971a103622
commit 421e13d72f

View file

@ -230,6 +230,11 @@ async function searchPrompt(allPrompts, tabId, tabType){
if (currentFocus >= items.length) currentFocus = 0;
if (currentFocus < 0) currentFocus = items.length - 1;
items[currentFocus].classList.add('mzta_autocomplete-item-active'); // Add "active" class to the current item
// Ensure the active item is visible within the scrollable list
items[currentFocus].scrollIntoView({
behavior: 'auto', // You can change to 'smooth' if you prefer smooth scrolling
block: 'nearest', // Align the item to the nearest edge of the visible area
});
}
// Function to remove the "active" class from all items