Skip to content

Commit f78548e

Browse files
jcorrea97rafaellmarques
authored andcommitted
fix(combo): corrige chamada repetida no componente
Corrige chamada repetida no componente após clicar no botão de limpar e realizar uma nova busca fixes DTHFUI-7500
1 parent bbdc281 commit f78548e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

projects/ui/src/lib/components/po-field/po-combo/po-combo-base.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,25 +1438,28 @@ describe('PoComboBaseComponent:', () => {
14381438

14391439
it('clear: should call `callModelChange` and `updateSelectedValue` and `updateComboList` and `initInputObservable`', () => {
14401440
component.clean = true;
1441-
1441+
component.keyupSubscribe = of('').subscribe();
14421442
spyOn(component, 'callModelChange');
14431443
spyOn(component, 'updateSelectedValue');
14441444
spyOn(component, 'updateComboList');
14451445
spyOn(component, 'initInputObservable');
1446+
spyOn(component.keyupSubscribe, 'unsubscribe');
14461447

14471448
component.clear('');
14481449

14491450
expect(component.callModelChange).toHaveBeenCalled();
14501451
expect(component.updateSelectedValue).toHaveBeenCalled();
14511452
expect(component.updateComboList).toHaveBeenCalled();
14521453
expect(component.initInputObservable).toHaveBeenCalled();
1454+
expect(component.keyupSubscribe['unsubscribe']).toHaveBeenCalled();
14531455
expect(component.selectedValue).toEqual(undefined);
14541456
});
14551457

14561458
it('clear: should set hasNext to true if `infiniteScrool` is true', () => {
14571459
component['defaultService'].hasNext = false;
14581460
component.infiniteScroll = true;
14591461
component.service = defaultService;
1462+
component.keyupSubscribe = of('').subscribe();
14601463

14611464
component.clear('');
14621465

projects/ui/src/lib/components/po-field/po-combo/po-combo-base.component.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,9 @@ export abstract class PoComboBaseComponent implements ControlValueAccessor, OnIn
887887
this.updateComboList();
888888
this.initInputObservable();
889889
this.updateHasNext();
890+
if (this.service || this.filterService) {
891+
this.keyupSubscribe.unsubscribe();
892+
}
890893
}
891894

892895
protected configAfterSetFilterService(service: PoComboFilter | string) {

0 commit comments

Comments
 (0)