Skip to content
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
10 changes: 9 additions & 1 deletion src/material-experimental/mdc-form-field/form-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,15 @@ export class MatFormField
}
set appearance(value: MatFormFieldAppearance) {
const oldValue = this._appearance;
this._appearance = value || this._defaults?.appearance || DEFAULT_APPEARANCE;
const newAppearance = value || this._defaults?.appearance || DEFAULT_APPEARANCE;
if (typeof ngDevMode === 'undefined' || ngDevMode) {
if (newAppearance !== 'fill' && newAppearance !== 'outline') {
throw new Error(
`MatFormField: Invalid appearance "${newAppearance}", valid values are "fill" or "outline".`,
);
}
}
this._appearance = newAppearance;
if (this._appearance === 'outline' && this._appearance !== oldValue) {
this._refreshOutlineNotchWidth();

Expand Down
2 changes: 1 addition & 1 deletion src/material/form-field/testing/shared.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export function runHarnessTests(
<span matTextSuffix *ngIf="isMdc">suffix_text</span>
</mat-form-field>

<mat-form-field appearance="standard" color="warn" id="with-errors">
<mat-form-field [appearance]="isMdc ? 'fill' : 'standard'" color="warn" id="with-errors">
<span class="custom-control">Custom control harness</span>
<input matInput [formControl]="requiredControl">

Expand Down