@@ -17,7 +17,7 @@ import {
1717import { NavigationStart , Router } from '@angular/router' ;
1818
1919import { BehaviorSubject , combineLatest , Observable , Subscription , of } from 'rxjs' ;
20- import { debounceTime , distinctUntilChanged , filter , map , switchMap , tap } from 'rxjs/operators' ;
20+ import { distinctUntilChanged , filter , map , switchMap , tap } from 'rxjs/operators' ;
2121import {
2222 NavigationStart ,
2323 Router ,
@@ -550,15 +550,16 @@ export class SearchComponent implements OnDestroy, OnInit {
550550 distinctUntilChanged ( ) ,
551551 ) ;
552552 const searchOptions$ : Observable < PaginatedSearchOptions > = this . getSearchOptions ( ) . pipe ( distinctUntilChanged ( ) ) ;
553+ const queryFromQueryParam$ : Observable < string > = this . routeService . getQueryParameterValue ( 'query' ) . pipe ( distinctUntilChanged ( ) ) ;
553554
554- this . subs . push ( combineLatest ( [ configuration$ , searchSortOptions$ , searchOptions$ , sortOption$ , this . currentScope$ ] ) . pipe (
555- filter ( ( [ configuration , searchSortOptions , searchOptions , sortOption , scope ] : [ string , SortOptions [ ] , PaginatedSearchOptions , SortOptions , string ] ) => {
555+ this . subs . push ( combineLatest ( [ configuration$ , searchSortOptions$ , searchOptions$ , sortOption$ , this . currentScope$ , queryFromQueryParam$ ] ) . pipe (
556+ filter ( ( [ configuration , searchSortOptions , searchOptions , sortOption , scope , queryFromQueryParam ] : [ string , SortOptions [ ] , PaginatedSearchOptions , SortOptions , string , string ] ) => {
556557 // filter for search options related to instanced paginated id
557558 return searchOptions . pagination . id === this . paginationId ;
558559 } ) ,
559- debounceTime ( 100 ) ,
560- ) . subscribe ( ( [ configuration , searchSortOptions , searchOptions , sortOption , scope ] :
561- [ string , SortOptions [ ] , PaginatedSearchOptions , SortOptions , string ] ) => {
560+ // debounceTime(100),
561+ ) . subscribe ( ( [ configuration , searchSortOptions , searchOptions , sortOption , scope , queryFromQueryParam ] :
562+ [ string , SortOptions [ ] , PaginatedSearchOptions , SortOptions , string , string ] ) => {
562563 // Always apply the freshly resolved configuration (do NOT keep stale one)
563564 const combinedOptions = Object . assign ( { } , searchOptions , {
564565 configuration,
@@ -568,6 +569,14 @@ export class SearchComponent implements OnDestroy, OnInit {
568569 if ( combinedOptions . query === '' ) {
569570 combinedOptions . query = this . query ;
570571 }
572+ if ( this . searchOptions$ . value ) {
573+ const currentOptions = this . searchOptions$ . value ;
574+ const query = currentOptions . query ;
575+ if ( isNotEmpty ( query ) && ( isEmpty ( combinedOptions . query ) || isEmpty ( queryFromQueryParam ) ) ) {
576+ combinedOptions . query = '' ;
577+ this . query = '' ;
578+ }
579+ }
571580 if ( isEmpty ( combinedOptions . scope ) ) {
572581 combinedOptions . scope = scope ;
573582 }
0 commit comments