From d5604b6fe02fda4cd38b772c06080acb4f7c555d Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Mon, 1 Mar 2021 11:15:10 -0700 Subject: [PATCH 1/3] fix(material-experimental/mdc-form-field): always check hideRequiredMarker --- src/material-experimental/mdc-form-field/form-field.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/material-experimental/mdc-form-field/form-field.ts b/src/material-experimental/mdc-form-field/form-field.ts index 8b70cae3c8cf..63ee64665b0d 100644 --- a/src/material-experimental/mdc-form-field/form-field.ts +++ b/src/material-experimental/mdc-form-field/form-field.ts @@ -314,7 +314,9 @@ export class MatFormField implements AfterViewInit, OnDestroy, AfterContentCheck @Inject(DOCUMENT) private _document?: any) { if (_defaults && _defaults.appearance) { this.appearance = _defaults.appearance; - } else if (_defaults && _defaults.hideRequiredMarker) { + } + + if (_defaults && _defaults.hideRequiredMarker) { this.hideRequiredMarker = true; } } From 0684ce2b8b78deff9bd8dc09acf2d602f94dc71c Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Tue, 2 Mar 2021 06:18:39 -0700 Subject: [PATCH 2/3] fix(material-experimental/mdc-form-field): add test --- src/material-experimental/mdc-input/input.spec.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/material-experimental/mdc-input/input.spec.ts b/src/material-experimental/mdc-input/input.spec.ts index 298d014b370c..60a4031acd96 100644 --- a/src/material-experimental/mdc-input/input.spec.ts +++ b/src/material-experimental/mdc-input/input.spec.ts @@ -1274,13 +1274,17 @@ describe('MatFormField default options', () => { expect(fixture.componentInstance.formField.hideRequiredMarker).toBe(false); }); - it('should be able to change the default value of hideRequiredMarker', () => { + it('should be able to change the default value of hideRequiredMarker and appearance', () => { const fixture = createComponent(MatInputWithAppearance, [{ - provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {hideRequiredMarker: true}} + provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { + hideRequiredMarker: true, + appearance: 'outline', + }} ]); fixture.detectChanges(); expect(fixture.componentInstance.formField.hideRequiredMarker).toBe(true); + expect(fixture.componentInstance.formField.appearance).toBe('outline'); }); }); From a22ced2ba57224ccc7cfdd3f6bfc1ba6e9194f01 Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Tue, 2 Mar 2021 07:46:41 -0700 Subject: [PATCH 3/3] fix(material-experimental/mdc-form-field): add test to legacy --- src/material/input/input.spec.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/material/input/input.spec.ts b/src/material/input/input.spec.ts index 6864c2012b34..9580b24f3cc5 100644 --- a/src/material/input/input.spec.ts +++ b/src/material/input/input.spec.ts @@ -1703,13 +1703,17 @@ describe('MatFormField default options', () => { expect(fixture.componentInstance.formField.hideRequiredMarker).toBe(false); }); - it('should be able to change the default value of hideRequiredMarker', () => { + it('should be able to change the default value of hideRequiredMarker and appearance', () => { const fixture = createComponent(MatInputWithAppearance, [{ - provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: {hideRequiredMarker: true}} + provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { + hideRequiredMarker: true, + appearance: 'outline', + }} ]); fixture.detectChanges(); expect(fixture.componentInstance.formField.hideRequiredMarker).toBe(true); + expect(fixture.componentInstance.formField.appearance).toBe('outline'); }); });