Skip to content

Commit

Permalink
Fixed broken search from main page
Browse files Browse the repository at this point in the history
* 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 )
  • Loading branch information
koliaBp committed Sep 1, 2022
1 parent 527b478 commit c55f581
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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());
}
}

Expand Down

0 comments on commit c55f581

Please sign in to comment.