diff --git a/projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.spec.ts b/projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.spec.ts index 5d61ef65741..f0b3bc4642f 100644 --- a/projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.spec.ts +++ b/projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.spec.ts @@ -73,6 +73,23 @@ describe('IgxAutocomplete', () => { fixture.detectChanges(); expect(dropDown.collapsed).toBeTruthy(); })); + it('Should close dropdown on Tab without calling super.handleKeyDown', fakeAsync(() => { + spyOn(autocomplete, 'handleKeyDown').and.callThrough(); + spyOn(IgxDropDownItemNavigationDirective.prototype, 'handleKeyDown').and.callThrough(); + + input.nativeElement.focus(); + UIInteractions.setInputElementValue(input, 's', fixture); + tick(); + expect(dropDown.collapsed).toBeFalsy(); + + // IgxDropDownItemNavigationDirective handleKeyDown is not called when dropdown is closed on Tab + UIInteractions.triggerKeyDownEvtUponElem('Tab', input.nativeElement, true); + fixture.detectChanges(); + tick(); + expect(dropDown.collapsed).toBeTruthy(); + expect(autocomplete.handleKeyDown).toHaveBeenCalledTimes(1); + expect(IgxDropDownItemNavigationDirective.prototype.handleKeyDown).toHaveBeenCalledTimes(0); + })); it('Should open drop down on (Alt+)ArrowUp/ArrowDown', fakeAsync(() => { UIInteractions.triggerKeyDownEvtUponElem('ArrowDown', input.nativeElement, true); tick(); diff --git a/projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.ts b/projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.ts index 4388c106310..00f8ba12d21 100644 --- a/projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.ts +++ b/projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.ts @@ -252,6 +252,7 @@ export class IgxAutocompleteDirective extends IgxDropDownItemNavigationDirective case ' ': case 'home': case 'end': + case 'tab': return; default: super.handleKeyDown(event);