From c55f5813a06b3314fbed8872f3c0dbcbaf9ea33e Mon Sep 17 00:00:00 2001 From: Kolia Date: Thu, 1 Sep 2022 14:31:39 +0300 Subject: [PATCH] Fixed broken search from main page * Added a command to clear the input when going to the main page * Replaced SetSearchQueryValue command with GetFilteredWorkshops ( Due to the filtering call in the method that moves to the result page, I see no reason to call it again ) --- .../filters-list/searchbar/searchbar.component.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/shared/components/filters-list/searchbar/searchbar.component.ts b/src/app/shared/components/filters-list/searchbar/searchbar.component.ts index 9cb0066475..681691e5aa 100644 --- a/src/app/shared/components/filters-list/searchbar/searchbar.component.ts +++ b/src/app/shared/components/filters-list/searchbar/searchbar.component.ts @@ -6,7 +6,7 @@ import { Observable, Subject } from 'rxjs'; import { debounceTime, distinctUntilChanged, filter, map, startWith, takeUntil, tap } from 'rxjs/operators'; import { NavBarName } from 'src/app/shared/enum/navigation-bar'; import { Navigation } from 'src/app/shared/models/navigation.model'; -import { SetSearchQueryValue } from 'src/app/shared/store/filter.actions'; +import { GetFilteredWorkshops, SetSearchQueryValue } from 'src/app/shared/store/filter.actions'; import { FilterState } from 'src/app/shared/store/filter.state'; import { NavigationState } from 'src/app/shared/store/navigation.state'; @Component({ @@ -53,6 +53,9 @@ export class SearchbarComponent implements OnInit, OnDestroy { this.searchQuery$ .pipe(takeUntil(this.destroy$)) .subscribe((text: string) => this.searchValueFormControl.setValue(text, { emitEvent: false })); + + if(!this.isResultPage) + this.searchValueFormControl.setValue('', { emitEvent: false }); } onValueEnter(): void { @@ -93,7 +96,8 @@ export class SearchbarComponent implements OnInit, OnDestroy { this.filteredResults = this.previousResults.filter((result: string) => result.toLowerCase().includes(value.toLowerCase())); } else { this.filteredResults = this.previousResults; - this.store.dispatch(new SetSearchQueryValue('')); + if(this.isResultPage) + this.store.dispatch(new GetFilteredWorkshops()); } }