Skip to content

Commit 80447dc

Browse files
committed
fix(combo): restore selection when id is changed
1 parent 5239aaf commit 80447dc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

+15-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,20 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
167167
*/
168168
@HostBinding('attr.id')
169169
@Input()
170-
public id = `igx-combo-${NEXT_ID++}`;
170+
public get id(): string {
171+
return this._id;
172+
}
173+
174+
public set id(value: string) {
175+
if (!value) {
176+
return;
177+
}
178+
const selection = this.selectionService.get(this._id);
179+
this._id = value;
180+
if (selection) {
181+
this.selectionService.set(this._id, selection);
182+
}
183+
}
171184

172185
/**
173186
* Sets the style width of the element
@@ -943,6 +956,7 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
943956
protected compareCollator = new Intl.Collator();
944957
protected computedStyles;
945958

959+
private _id: string = `igx-combo-${NEXT_ID++}`;
946960
private _type = null;
947961
private _dataType = '';
948962
private _itemHeight = null;

0 commit comments

Comments
 (0)