Skip to content

Commit ac30d52

Browse files
Merge branch '20.0.x' into ikitanov/fix-15839
2 parents 3efa9f5 + ea24646 commit ac30d52

File tree

6 files changed

+29
-2
lines changed

6 files changed

+29
-2
lines changed

projects/igniteui-angular/src/lib/combo/combo-dropdown.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export class IgxComboDropDownComponent extends IgxDropDownComponent implements I
177177
this.handleSpace();
178178
break;
179179
case DropDownActionKey.ESCAPE:
180+
case DropDownActionKey.TAB:
180181
this.close();
181182
}
182183
}

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1943,6 +1943,16 @@ describe('igxCombo', () => {
19431943
fixture.detectChanges();
19441944
expect(firstVisibleItem.classList.contains(CSS_CLASS_FOCUSED)).toBeTruthy();
19451945
}));
1946+
it('should close the dropdown list on pressing Tab key', fakeAsync(() => {
1947+
combo.toggle();
1948+
fixture.detectChanges();
1949+
1950+
const dropdownContent = fixture.debugElement.query(By.css(`.${CSS_CLASS_CONTENT}`));
1951+
UIInteractions.triggerEventHandlerKeyDown('Tab', dropdownContent);
1952+
tick();
1953+
fixture.detectChanges();
1954+
expect(combo.collapsed).toBeTruthy();
1955+
}));
19461956
});
19471957
describe('primitive data dropdown: ', () => {
19481958
it('should properly navigate with HOME/END keys when no virtScroll is necessary', async () => {

projects/igniteui-angular/src/lib/drop-down/drop-down-navigation.directive.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class IgxDropDownItemNavigationDirective implements IDropDownNavigationDi
6767
const key = event.key.toLowerCase();
6868
if (!this.target.collapsed) { // If dropdown is opened
6969
const navKeys = ['esc', 'escape', 'enter', 'space', 'spacebar', ' ',
70-
'arrowup', 'up', 'arrowdown', 'down', 'home', 'end'];
70+
'arrowup', 'up', 'arrowdown', 'down', 'home', 'end', 'tab'];
7171
if (navKeys.indexOf(key) === -1) { // If key has appropriate function in DD
7272
return;
7373
}
@@ -103,6 +103,9 @@ export class IgxDropDownItemNavigationDirective implements IDropDownNavigationDi
103103
case 'end':
104104
this.onEndKeyDown();
105105
break;
106+
case 'tab':
107+
this.target.onItemActionKey(DropDownActionKey.TAB, event);
108+
break;
106109
default:
107110
return;
108111
}

projects/igniteui-angular/src/lib/drop-down/drop-down.base.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export abstract class IgxDropDownBaseDirective implements IDropDownList, OnInit
206206
this.selectItem(this.focusedItem, event);
207207
break;
208208
case DropDownActionKey.ESCAPE:
209+
case DropDownActionKey.TAB:
209210
}
210211
}
211212

projects/igniteui-angular/src/lib/drop-down/drop-down.common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export enum Navigate {
1313
export const DropDownActionKey = {
1414
ESCAPE: 'escape',
1515
ENTER: 'enter',
16-
SPACE: 'space'
16+
SPACE: 'space',
17+
TAB: 'tab'
1718
} as const;
1819
export type DropDownActionKey = (typeof DropDownActionKey)[keyof typeof DropDownActionKey];
1920

projects/igniteui-angular/src/lib/simple-combo/simple-combo.component.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,17 @@ describe('IgxSimpleCombo', () => {
11961196
expect(combo.selection).toBeDefined()
11971197
});
11981198

1199+
it('should close the dropdown list on pressing Tab key', fakeAsync(() => {
1200+
combo.open();
1201+
fixture.detectChanges();
1202+
1203+
const dropdownContent = fixture.debugElement.query(By.css(`.${CSS_CLASS_CONTENT}`));
1204+
UIInteractions.triggerEventHandlerKeyDown('Tab', dropdownContent);
1205+
tick();
1206+
fixture.detectChanges();
1207+
expect(combo.collapsed).toBeTruthy();
1208+
}));
1209+
11991210
it('should clear the selection on tab/blur if the search text does not match any value', () => {
12001211
// allowCustomValues does not matter
12011212
combo.select(combo.data[2][combo.valueKey]);

0 commit comments

Comments
 (0)