Skip to content

Commit c7dc338

Browse files
authored
Merge branch '18.0.x' into aahmedov/fix-filterCellClick-14322-18.0.x
2 parents f080b87 + d825d99 commit c7dc338

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,8 @@ export class IgxButtonGroupComponent implements AfterViewInit, OnDestroy {
517517
if (updatedButtons.length > 0) {
518518
updatedButtons.forEach((button) => {
519519
const index = this.buttons.map((b) => b.nativeElement).indexOf(button);
520-
const args: IButtonGroupEventArgs = { owner: this, button: this.buttons[index], index };
521520

522-
this.updateButtonSelectionState(index, args);
521+
this.updateButtonSelectionState(index);
523522
});
524523
}
525524

@@ -544,13 +543,11 @@ export class IgxButtonGroupComponent implements AfterViewInit, OnDestroy {
544543
return updated;
545544
}
546545

547-
private updateButtonSelectionState(index: number, args: IButtonGroupEventArgs) {
546+
private updateButtonSelectionState(index: number) {
548547
if (this.buttons[index].selected) {
549548
this.updateSelected(index);
550-
this.selected.emit(args);
551549
} else {
552550
this.updateDeselected(index);
553-
this.deselected.emit(args);
554551
}
555552
}
556553
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,32 @@ describe('IgxButtonGroup', () => {
434434
expect(buttonGroup.buttons[0].nativeElement.classList.contains('igx-button-group__item--selected')).toBe(false);
435435
});
436436

437+
it('should emit selected event only once per selection', async() => {
438+
const fixture = TestBed.createComponent(InitButtonGroupComponent);
439+
fixture.detectChanges();
440+
await wait();
441+
442+
const buttonGroup = fixture.componentInstance.buttonGroup;
443+
444+
spyOn(buttonGroup.selected, 'emit').and.callThrough();
445+
446+
buttonGroup.selectButton(0);
447+
await wait();
448+
fixture.detectChanges();
449+
450+
const buttons = fixture.nativeElement.querySelectorAll('button');
451+
buttons[1].click();
452+
await wait();
453+
fixture.detectChanges();
454+
455+
expect(buttonGroup.selected.emit).toHaveBeenCalledTimes(1);
456+
457+
buttons[0].click();
458+
await wait();
459+
fixture.detectChanges();
460+
461+
expect(buttonGroup.selected.emit).toHaveBeenCalledTimes(2);
462+
});
437463
});
438464

439465
@Component({

0 commit comments

Comments
 (0)