Skip to content

Commit

Permalink
fix(radio-button): no random suffix for custom ID (#1116)
Browse files Browse the repository at this point in the history
  • Loading branch information
vt-allianz authored and GitHub Enterprise committed Feb 1, 2024
1 parent cc5f666 commit 65d9828
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion projects/ng-aquila/src/radio-button/radio-button.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ describe('NxRadioComponent', () => {
radioInstance.id = 'custom-radio-id';
fixture.detectChanges();
const radioElement = fixture.nativeElement.querySelector('nx-radio');
expect(getRadioInputElement(radioElement).getAttribute('id')?.startsWith('custom-radio-id-input')).toBeTrue();
expect(getRadioInputElement(radioElement).getAttribute('id')).toBe('custom-radio-id-input');
expect(getRadioLabelElement(radioElement).getAttribute('id')).toBe('custom-radio-id-label');
});

Expand Down
5 changes: 2 additions & 3 deletions projects/ng-aquila/src/radio-button/radio-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,12 @@ export class NxRadioComponent implements ControlValueAccessor, OnInit, AfterView
get id(): string {
return this._id;
}
private _id = `nx-radio-${nextId++}`;

private _inputIdSuffix = randomString();
private _id = `nx-radio-${nextId++}-${randomString()}`;

/** @docs-private */
get inputId(): string {
return `${this.id}-input-${this._inputIdSuffix}`;
return `${this.id}-input`;
}

/** @docs-private */
Expand Down

0 comments on commit 65d9828

Please sign in to comment.