Skip to content

Commit c4c8fd3

Browse files
committed
fix(autocomplete): do not call super.handleKeyDown on Tab
1 parent 404ad9a commit c4c8fd3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.spec.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,23 @@ describe('IgxAutocomplete', () => {
7373
fixture.detectChanges();
7474
expect(dropDown.collapsed).toBeTruthy();
7575
}));
76+
it('Should close dropdown on Tab without calling super.handleKeyDown', fakeAsync(() => {
77+
spyOn(autocomplete, 'handleKeyDown').and.callThrough();
78+
spyOn(IgxDropDownItemNavigationDirective.prototype, 'handleKeyDown').and.callThrough();
79+
80+
input.nativeElement.focus();
81+
UIInteractions.setInputElementValue(input, 's', fixture);
82+
tick();
83+
expect(dropDown.collapsed).toBeFalsy();
84+
85+
// IgxDropDownItemNavigationDirective handleKeyDown is not called when dropdown is closed on Tab
86+
UIInteractions.triggerKeyDownEvtUponElem('Tab', input.nativeElement, true);
87+
fixture.detectChanges();
88+
tick();
89+
expect(dropDown.collapsed).toBeTruthy();
90+
expect(autocomplete.handleKeyDown).toHaveBeenCalledTimes(1);
91+
expect(IgxDropDownItemNavigationDirective.prototype.handleKeyDown).toHaveBeenCalledTimes(0);
92+
}));
7693
it('Should open drop down on (Alt+)ArrowUp/ArrowDown', fakeAsync(() => {
7794
UIInteractions.triggerKeyDownEvtUponElem('ArrowDown', input.nativeElement, true);
7895
tick();

projects/igniteui-angular/drop-down/src/drop-down/autocomplete/autocomplete.directive.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ export class IgxAutocompleteDirective extends IgxDropDownItemNavigationDirective
252252
case ' ':
253253
case 'home':
254254
case 'end':
255+
case 'tab':
255256
return;
256257
default:
257258
super.handleKeyDown(event);

0 commit comments

Comments
 (0)