Skip to content

MDC-based form-field doesn't inherit custom typography #23509

Open
@kaspnilsson

Description

@kaspnilsson

Affected component[s]: Form field

Observed behavior:

Outlined input's floating label does not comply with custom typography -- only applies to MDC component.

In addition, MDC component does not shrink in height the same way the non-MDC component does -- not sure why this would be

To actually reproduce this, you unfortunately need to create two separate modules and export two separate components so the [matInput] directives don't collide, but this is the gist of the repro case:

Code:

<div class="non-mdc">
  <mat-form-field appearance="outline">
    <mat-label>Non-MDC label</mat-label>
    <input matInput placeholder="A placeholder"  />
  </mat-form-field>
</div>
<div class="mdc">
  <mat-form-field appearance="outline">
    <mat-label>MDC label</mat-label>
    <input matInput placeholder="A placeholder"  />
  </mat-form-field>
</div>
.non-mdc {
  @include mat.form-field-theme($app-theme); // some init theme
}

$small-typography: mat.define-typography-level(12px, 16px, 400, $roboto-font, 0.3px);

$form-field-typography: mat.define-typography-config(
  $body-2: $small-typography,
  $subheading-1: $small-typography,
  $input: $small-typography,
);

.mdc {
  @include mat.mdc-form-field-theme($app-theme); // some init theme
  @include mat.mdc-form-field-typography($form-field-typography);
}

.mdc,
.non-mdc {
  font-size: 12px;
}

Screen recording:

Unnamed.screen.capture.4.mp4

Expected behavior:

  • Floating label is definitely wrong
  • Feature parity with upgrade re: input height auto-resizing may be desirable, not sure. May also be related to the first problem somehow

Metadata

Metadata

Assignees

No one assigned

    Labels

    GThis is is related to a Google internal issueP2The issue is important to a large percentage of users, with a workaroundarea: material/form-field

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions