Merged PR 1351: #3304 Fix WA Autocomplete Dropdown closing after queryParams change

#3304 Fix WA Autocomplete Dropdown closing after queryParams change
This commit is contained in:
Nino Righi
2022-07-26 14:57:11 +00:00
committed by Lorenz Hilpert
parent b5cfcf8036
commit 4ae5759361

View File

@@ -3,8 +3,8 @@ import { ActivatedRoute, Router } from '@angular/router';
import { BreadcrumbService } from '@core/breadcrumb';
import { OrderItemListItemDTO } from '@swagger/oms';
import { debounce, isEqual } from 'lodash';
import { combineLatest, Subscription } from 'rxjs';
import { debounceTime, first, map } from 'rxjs/operators';
import { BehaviorSubject, combineLatest, Subscription } from 'rxjs';
import { debounceTime, first, map, withLatestFrom } from 'rxjs/operators';
import { GoodsOutSearchStore } from '../goods-out-search.store';
@Component({
@@ -18,6 +18,8 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
loading$ = this._goodsOutSearchStore.fetching$;
queryChanged$ = new BehaviorSubject<boolean>(false);
message: string;
lastProcessId: number | undefined;
@@ -50,11 +52,12 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
this._subscriptions.add(
combineLatest([this.processId$, this._activatedRoute.queryParams])
.pipe(debounceTime(50))
.subscribe(([processId, queryParams]) => {
if (!isEqual(queryParams, this._goodsOutSearchStore.filter?.getQueryParams())) {
.pipe(debounceTime(50), withLatestFrom(this.queryChanged$))
.subscribe(([[processId, queryParams], queryChanged]) => {
if (!isEqual(queryParams, this._goodsOutSearchStore.filter?.getQueryParams()) && !queryChanged) {
this._goodsOutSearchStore.resetFilter(queryParams);
}
this.queryChanged$.next(false);
this.removeBreadcrumbs(processId);
this.updateBreadcrumb(processId, queryParams);
})
@@ -135,5 +138,8 @@ export class GoodsOutSearchMainComponent implements OnInit, OnDestroy {
: `/kunde/${processId}/goods/out/details/order/${encodeURIComponent(item?.orderNumber)}/${item?.processingStatus}`;
}
queryChangeDebounce = debounce(() => this.updateQueryParams(this.processId), 500);
queryChangeDebounce = debounce(async () => {
this.queryChanged$.next(true);
await this.updateQueryParams(this.processId);
}, 500);
}