diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b818138..a4f84c3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ This release requires TypeScript >=2.8.0 for the conditional type support. * add `notEqualTo` validation function ([851a1ed](https://github.com/MrWolfZ/ngrx-forms/commit/851a1ed)) * enhance all form state reducers to match type signature for `ActionReducer` (they will still throw an error if the state is `undefined`) ([f3b5fea](https://github.com/MrWolfZ/ngrx-forms/commit/f3b5fea)) +#### Bugfixes + +* do not set the `id` attribute for `input[type=radio]` form elements, closes [#63](https://github.com/MrWolfZ/ngrx-forms/issues/63) + ### 2.3.2 diff --git a/src/control/e2e.spec/radio.spec.ts b/src/control/e2e.spec/radio.spec.ts index 8c7ab87e..81ead49b 100644 --- a/src/control/e2e.spec/radio.spec.ts +++ b/src/control/e2e.spec/radio.spec.ts @@ -70,6 +70,11 @@ describe(RadioTestComponent.name, () => { expect(element2.name).toBe(newId); }); + it('should not set the id of any element', () => { + expect(element1.id).not.toBe(INITIAL_STATE.id); + expect(element2.id).not.toBe(INITIAL_STATE.id); + }); + it('should select the correct option initially', () => { expect(element2.checked).toBe(true); }); diff --git a/src/view-adapter/default.ts b/src/view-adapter/default.ts index ab872110..03b344ac 100644 --- a/src/view-adapter/default.ts +++ b/src/view-adapter/default.ts @@ -14,10 +14,14 @@ function isAndroid(): boolean { } // tslint:disable:directive-class-suffix +// tslint:disable:directive-selector +// TODO: since this directive has a side-effect (setting the element's id attribute) +// it should not blacklist other types of inputs but instead it should somehow figure +// out whether it is the "active" view adapter and only perform its side effects if it +// is active @Directive({ - // tslint:disable-next-line:directive-selector - selector: 'input:not([type=checkbox])[ngrxFormControlState],textarea[ngrxFormControlState]', + selector: 'input:not([type=checkbox]):not([type=number]):not([type=radio]):not([type=range])[ngrxFormControlState],textarea[ngrxFormControlState]', providers: [{ provide: NGRX_FORM_VIEW_ADAPTER, useExisting: forwardRef(() => NgrxDefaultViewAdapter),