From 5d22fc76b4f03f417c6fce41c3112cd569e0a288 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Wed, 3 Apr 2024 00:32:19 -0700 Subject: [PATCH] circular keyboard navigation, fix with no results --- .../app-frame/global-search/global-search.component.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.ts b/src-ui/src/app/components/app-frame/global-search/global-search.component.ts index 28e1e800a..6550964e6 100644 --- a/src-ui/src/app/components/app-frame/global-search/global-search.component.ts +++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.ts @@ -73,15 +73,19 @@ export class GlobalSearchComponent { ) { if (event.key === 'ArrowDown') { if (this.currentItemIndex < this.searchResults.total - 1) { + event.preventDefault() this.currentItemIndex++ this.setCurrentItem() + } else { event.preventDefault() + this.currentItemIndex = 0 + this.setCurrentItem() } } else if (event.key === 'ArrowUp') { if (this.currentItemIndex > 0) { + event.preventDefault() this.currentItemIndex-- this.setCurrentItem() - event.preventDefault() } else { this.searchInput.nativeElement.focus() this.currentItemIndex = -1 @@ -267,9 +271,10 @@ export class GlobalSearchComponent { public searchInputKeyDown(event: KeyboardEvent) { if ( event.key === 'ArrowDown' && - this.searchResults && + this.searchResults?.total && this.resultsDropdown.isOpen() ) { + event.preventDefault() this.currentItemIndex = 0 this.setCurrentItem() } else if (