Skip to content

Commit 6ba84e6

Browse files
authored
Merge pull request #14548 from IgniteUI/ganastasov/fix-14539-17.2.x
fix(combo): resolve error in dropdown component by setting id - 17.2.x
2 parents 4331ca8 + 38a2b4c commit 6ba84e6

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

projects/igniteui-angular/src/lib/combo/combo.common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
180180
if (selection) {
181181
this.selectionService.set(this._id, selection);
182182
}
183-
if (this.dropdown.open) {
183+
if (this.dropdown?.open) {
184184
this.dropdown.close();
185185
}
186186
if (this.inputGroup?.isFocused) {

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,22 @@ describe('igxCombo', () => {
11531153
caseSensitiveIcon = fixture.debugElement.query(By.css('igx-icon[name=\'case-sensitive\']'));
11541154
expect(caseSensitiveIcon).toBeNull();
11551155
});
1156+
it('should render the combo component with the id set and not throw an error', () => {
1157+
fixture = TestBed.createComponent(ComboWithIdComponent);
1158+
fixture.detectChanges();
1159+
1160+
combo = fixture.componentInstance.combo;
1161+
fixture.detectChanges();
1162+
1163+
expect(combo).toBeTruthy();
1164+
expect(combo.id).toEqual("id1");
1165+
fixture.detectChanges();
1166+
1167+
const errorSpy = spyOn(console, 'error');
1168+
fixture.detectChanges();
1169+
1170+
expect(errorSpy).not.toHaveBeenCalled();
1171+
});
11561172
});
11571173
describe('Positioning tests: ', () => {
11581174
let containerElement: any;
@@ -3875,3 +3891,32 @@ export class ComboArrayTypeValueKeyComponent {
38753891
];
38763892
}
38773893
}
3894+
3895+
@Component({
3896+
template: `
3897+
<igx-combo id="id1" [data]="items" valueKey="value" displayKey="item"></igx-combo>`,
3898+
standalone: true,
3899+
imports: [IgxComboComponent]
3900+
})
3901+
export class ComboWithIdComponent {
3902+
@ViewChild(IgxComboComponent, { read: IgxComboComponent, static: true })
3903+
public combo: IgxComboComponent;
3904+
public items: any[] = [];
3905+
3906+
constructor() {
3907+
this.items = [
3908+
{
3909+
item: "Item1",
3910+
value: "Option1"
3911+
},
3912+
{
3913+
item: "Item2",
3914+
value: "Option2"
3915+
},
3916+
{
3917+
item: "Item3",
3918+
value: "Option3",
3919+
}
3920+
];
3921+
}
3922+
}

0 commit comments

Comments
 (0)