diff --git a/projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal-base.component.ts b/projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal-base.component.ts index efc1011ca..14d3b3562 100644 --- a/projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal-base.component.ts +++ b/projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal-base.component.ts @@ -265,7 +265,8 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit { this.language = languageService.getShortLanguage(); } - ngOnDestroy() { + // Metodo responsavel por cancelar todas as requisiçoes pendentes + unsubscribeAllSubscriptions() { if (this.filterSubscription) { this.filterSubscription.unsubscribe(); } @@ -279,6 +280,10 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit { } } + ngOnDestroy() { + this.unsubscribeAllSubscriptions(); + } + ngOnInit() { this.setAdvancedFilterModalProperties(); this.initializeData(); @@ -336,7 +341,7 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit { search(): void { this.page = 1; - + this.unsubscribeAllSubscriptions(); if (this.searchValue) { this.isLoading = true; this.disclaimerGroup.disclaimers = []; @@ -348,6 +353,9 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit { } searchFilteredItems(): void { + if (this.isLoading) { + this.unsubscribeAllSubscriptions(); + } this.searchSubscription = this.getFilteredItems(this.searchValue) .pipe( catchError(error => { @@ -362,6 +370,10 @@ export abstract class PoLookupModalBaseComponent implements OnDestroy, OnInit { } showMoreEvent() { + if (this.isLoading) { + this.unsubscribeAllSubscriptions(); + } + this.page++; this.isLoading = true; diff --git a/projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal.component.html b/projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal.component.html index 16a538bcb..0b7fe1ff8 100644 --- a/projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal.component.html +++ b/projects/ui/src/lib/components/po-field/po-lookup/po-lookup-modal/po-lookup-modal.component.html @@ -5,6 +5,7 @@ [p-primary-action]="isAdvancedFilter ? primaryActionAdvancedFilter : primaryAction" [p-secondary-action]="isAdvancedFilter ? secondaryActionAdvancedFilter : secondaryAction" [p-title]="isAdvancedFilter ? advancedFilterModalTitle : title" + (p-close)="unsubscribeAllSubscriptions()" >