From cf2b933a70807b306cb42c2c9fd8be2843ef0522 Mon Sep 17 00:00:00 2001 From: GabrielMeyer Date: Tue, 27 Aug 2019 16:27:49 +0200 Subject: [PATCH] Hotfix for global search --- .../src/app/core/ui-services/search.service.ts | 4 +++- .../super-search/super-search.component.ts | 18 ++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/client/src/app/core/ui-services/search.service.ts b/client/src/app/core/ui-services/search.service.ts index 9dd09f186..c32b809e9 100644 --- a/client/src/app/core/ui-services/search.service.ts +++ b/client/src/app/core/ui-services/search.service.ts @@ -213,7 +213,9 @@ export class SearchService { .filter(model => dedicatedId ? model.id === dedicatedId - : model.formatForSearch().searchValue.some(text => text.toLowerCase().indexOf(query) !== -1) + : model + .formatForSearch() + .searchValue.some(text => text && text.toLowerCase().indexOf(query) !== -1) ) .sort((a, b) => { switch (sortingProperty) { diff --git a/client/src/app/site/common/components/super-search/super-search.component.ts b/client/src/app/site/common/components/super-search/super-search.component.ts index 3a2f11adb..e8b36e835 100644 --- a/client/src/app/site/common/components/super-search/super-search.component.ts +++ b/client/src/app/site/common/components/super-search/super-search.component.ts @@ -304,14 +304,16 @@ export class SuperSearchComponent implements OnInit { * @param event KeyboardEvent to listen to keyboard-inputs. */ @HostListener('document:keydown', ['$event']) public onKeyNavigation(event: KeyboardEvent): void { - if (event.key === 'Enter') { - this.viewResult(this.selectedModel); - } - if (event.key === 'ArrowUp') { - this.selectNextResult(true); - } - if (event.key === 'ArrowDown') { - this.selectNextResult(false); + if (!!this.selectedModel) { + if (event.key === 'Enter') { + this.viewResult(this.selectedModel); + } + if (event.key === 'ArrowUp') { + this.selectNextResult(true); + } + if (event.key === 'ArrowDown') { + this.selectNextResult(false); + } } if (event.altKey && event.shiftKey && event.key === 'V') { this.showPreview = !this.showPreview;