Skip to content

Commit 10ca6ab

Browse files
Merge pull request #13973 from IgniteUI/ikitanov/fix-13691-16.1.x
Resolve buttons not selected if initialized after the group
2 parents 20e461b + 5c8a8c7 commit 10ca6ab

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

projects/igniteui-angular/src/lib/buttonGroup/buttonGroup.component.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -460,15 +460,22 @@ export class IgxButtonGroupComponent extends DisplayDensityBase implements After
460460
});
461461
};
462462

463-
this.viewButtons.changes.pipe(takeUntil(this.queryListNotifier$)).subscribe(() => initButtons());
464-
this.templateButtons.changes.pipe(takeUntil(this.queryListNotifier$)).subscribe(() => initButtons());
465-
initButtons();
466-
467-
this._cdr.detectChanges();
468-
469463
this.mutationObserver = this.setMutationsObserver();
470464

471-
this.mutationObserver.observe(this._el.nativeElement, this.observerConfig);
465+
this.viewButtons.changes.pipe(takeUntil(this.queryListNotifier$)).subscribe(() => {
466+
this.mutationObserver.disconnect();
467+
initButtons();
468+
this.mutationObserver?.observe(this._el.nativeElement, this.observerConfig);
469+
});
470+
this.templateButtons.changes.pipe(takeUntil(this.queryListNotifier$)).subscribe(() => {
471+
this.mutationObserver.disconnect();
472+
initButtons();
473+
this.mutationObserver?.observe(this._el.nativeElement, this.observerConfig);
474+
});
475+
476+
initButtons();
477+
this._cdr.detectChanges();
478+
this.mutationObserver?.observe(this._el.nativeElement, this.observerConfig);
472479
}
473480

474481
/**

0 commit comments

Comments
 (0)