Fix hook and add keyboard navigation tests

Co-authored-by: cloud8421 <537608+cloud8421@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-09 17:31:30 +00:00
committed by Claudio Ortolina
parent df55065b32
commit 36d1ba1b48
2 changed files with 45 additions and 4 deletions
@@ -1,6 +1,5 @@
export default {
mounted() {
this.searchInput = document.getElementById("universal-search-input");
this.selectedIndex = -1; // -1 means search input is focused
this.keydownHandler = (event) => {
@@ -89,15 +88,16 @@ export default {
updateSelection() {
const results = this.getResultElements();
// Remove all aria-selected attributes and return focus to search input
// Remove all aria-selected attributes
results.forEach((result) => {
result.removeAttribute("aria-selected");
});
if (this.selectedIndex === -1) {
// Focus search input
if (this.searchInput) {
this.searchInput.focus();
const searchInput = document.getElementById("universal-search-input");
if (searchInput) {
searchInput.focus();
}
} else if (this.selectedIndex >= 0 && this.selectedIndex < results.length) {
// Mark selected result