Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(material-experimental/mdc-form-field): always check hideRequiredMarker #22068

Merged
merged 3 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/material-experimental/mdc-form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/material-experimental/mdc-input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

});
Expand Down
8 changes: 6 additions & 2 deletions src/material/input/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

});
Expand Down