Skip to content

Commit

Permalink
Fixed #9631 - Radio buttons do not get unselected on the same group, …
Browse files Browse the repository at this point in the history
…with Reactive Forms using formControl instead of formControlName
  • Loading branch information
yigitfindikli committed Apr 26, 2021
1 parent 7483da7 commit e69486b
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/app/components/radiobutton/radiobutton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,9 @@ export class RadioButton implements ControlValueAccessor, OnInit, OnDestroy {
constructor(public cd: ChangeDetectorRef, private injector: Injector, private registry: RadioControlRegistry) {}

ngOnInit() {
if (this.formControlName) {
this.control = this.injector.get(NgControl);
this.checkName();
this.registry.add(this.control, this);
}
this.control = this.injector.get(NgControl);
this.checkName();
this.registry.add(this.control, this);
}

handleClick(event, radioButton, focus) {
Expand All @@ -133,11 +131,7 @@ export class RadioButton implements ControlValueAccessor, OnInit, OnDestroy {
this.inputViewChild.nativeElement.checked = true;
this.checked = true;
this.onModelChange(this.value);

if (this.formControlName) {
this.registry.select(this);
}

this.registry.select(this);
this.onClick.emit(event);
}
}
Expand Down Expand Up @@ -185,9 +179,7 @@ export class RadioButton implements ControlValueAccessor, OnInit, OnDestroy {
}

ngOnDestroy() {
if (this.formControlName) {
this.registry.remove(this);
}
this.registry.remove(this);
}

private checkName() {
Expand Down

0 comments on commit e69486b

Please sign in to comment.