Skip to content

Commit 588e471

Browse files
fix(simple-combo): prevent group header selection on Enter key press - 18.0.x (#14431)
1 parent 55f99c0 commit 588e471

File tree

4 files changed

+43
-4
lines changed

4 files changed

+43
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ All notable changes for each version of this project will be documented in this
7878
- The `contextMenu` event now fires when the end-user clicks to the right of the right-most cell in the grid in case the grid's columns don't span its full width. For this reason the event argument of the event is now of type `IGridContextMenuEventArgs` which contains the row object as well as the cell one. The latter will be `null` if the event didn't originate from a cell. **This is not a breaking change** as the new type extends the old.
7979
- `IgxSimpleCombo`
8080
- **Behavioral Change** The `selectionChanging` event will now trigger when typing the first character in the input if there is a previously selected value in the `IgxSimpleCombo`.
81+
- **Behavioral Change** Updated behavior to maintain the entered text in the input field upon pressing Enter while the combo input is focused, ensuring uninterrupted focus for continuous filtering. Additionally, the dropdown menu now remains open to display filtered results.
8182

8283
## 17.1.0
8384
### New Features

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ export class IgxComboDropDownComponent extends IgxDropDownComponent implements I
127127
public override navigatePrev() {
128128
if (this._focusedItem && this._focusedItem.index === 0 && this.virtDir.state.startIndex === 0) {
129129
this.combo.focusSearchInput(false);
130+
this.focusedItem = null;
130131
} else {
131132
super.navigatePrev();
132133
}

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

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,6 +1734,36 @@ describe('IgxSimpleCombo', () => {
17341734
expect(combo.filteredData.length).toEqual(1);
17351735
expect(combo.filteredData[0].field).toEqual('Arizona');
17361736
}));
1737+
1738+
it('should not select the first item when combo is focused there is no focus item and Enter is pressed', fakeAsync(() => {
1739+
combo.open();
1740+
tick();
1741+
fixture.detectChanges();
1742+
1743+
UIInteractions.simulateTyping('ariz', input);
1744+
tick();
1745+
fixture.detectChanges();
1746+
1747+
expect(combo.dropdown.collapsed).toBe(false);
1748+
1749+
UIInteractions.triggerKeyDownEvtUponElem('ArrowDown', input.nativeElement);
1750+
tick();
1751+
fixture.detectChanges();
1752+
1753+
input.nativeElement.focus();
1754+
tick();
1755+
fixture.detectChanges();
1756+
1757+
combo.dropdown.focusedItem = undefined;
1758+
tick();
1759+
fixture.detectChanges();
1760+
1761+
UIInteractions.triggerKeyDownEvtUponElem('Enter', input.nativeElement);
1762+
tick();
1763+
fixture.detectChanges();
1764+
1765+
expect(combo.comboInput.value).toEqual('ariz');
1766+
}));
17371767
});
17381768

17391769
describe('Display density', () => {

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,17 @@ export class IgxSimpleComboComponent extends IgxComboBaseDirective implements Co
329329
return;
330330
}
331331
if (!this.dropdown.collapsed) {
332-
this.select(this.dropdown.focusedItem.itemID);
333-
event.preventDefault();
334-
event.stopPropagation();
335-
this.close();
332+
const focusedItem = this.dropdown.focusedItem;
333+
if (focusedItem && !focusedItem.isHeader) {
334+
this.select(focusedItem.itemID);
335+
event.preventDefault();
336+
event.stopPropagation();
337+
this.close();
338+
} else {
339+
event.preventDefault();
340+
event.stopPropagation();
341+
this.comboInput.focus();
342+
}
336343
}
337344
// manually trigger text selection as it will not be triggered during editing
338345
this.textSelection.trigger();

0 commit comments

Comments
 (0)