Skip to content

Commit 8919bd5

Browse files
fix(combo): resolve error in dropdown component by updating id binding syntax
1 parent 5318c5f commit 8919bd5

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 implements IgxComboBase, AfterViewCh
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
@@ -1154,6 +1154,22 @@ describe('igxCombo', () => {
11541154
caseSensitiveIcon = fixture.debugElement.query(By.css('igx-icon[name=\'case-sensitive\']'));
11551155
expect(caseSensitiveIcon).toBeNull();
11561156
});
1157+
it('should render the combo component with the id set and not throw an error', () => {
1158+
fixture = TestBed.createComponent(ComboWithIdComponent);
1159+
fixture.detectChanges();
1160+
1161+
combo = fixture.componentInstance.combo;
1162+
fixture.detectChanges();
1163+
1164+
expect(combo).toBeTruthy();
1165+
expect(combo.id).toEqual("id1");
1166+
fixture.detectChanges();
1167+
1168+
const errorSpy = spyOn(console, 'error');
1169+
fixture.detectChanges();
1170+
1171+
expect(errorSpy).not.toHaveBeenCalled();
1172+
});
11571173
});
11581174
describe('Positioning tests: ', () => {
11591175
let containerElement: any;
@@ -3846,3 +3862,32 @@ export class ComboArrayTypeValueKeyComponent {
38463862
];
38473863
}
38483864
}
3865+
3866+
@Component({
3867+
template: `
3868+
<igx-combo id="id1" [data]="items" valueKey="value" displayKey="item"></igx-combo>`,
3869+
standalone: true,
3870+
imports: [IgxComboComponent]
3871+
})
3872+
export class ComboWithIdComponent {
3873+
@ViewChild(IgxComboComponent, { read: IgxComboComponent, static: true })
3874+
public combo: IgxComboComponent;
3875+
public items: any[] = [];
3876+
3877+
constructor() {
3878+
this.items = [
3879+
{
3880+
item: "Item1",
3881+
value: "Option1"
3882+
},
3883+
{
3884+
item: "Item2",
3885+
value: "Option2"
3886+
},
3887+
{
3888+
item: "Item3",
3889+
value: "Option3",
3890+
}
3891+
];
3892+
}
3893+
}

0 commit comments

Comments
 (0)