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

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

Open
kaspnilsson opened this issue Sep 1, 2021 · 2 comments
Open

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

kaspnilsson opened this issue Sep 1, 2021 · 2 comments
Labels
area: material/form-field G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround

Comments

@kaspnilsson
Copy link

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
@kaspnilsson kaspnilsson added the needs triage This issue needs to be triaged by the team label Sep 1, 2021
@jelbourn jelbourn changed the title bug(MDC_FORM_FIELD): TITLE MDC-based form-field doesn't inherit custom typography Sep 2, 2021
@jelbourn jelbourn added area: material/form-field G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround and removed needs triage This issue needs to be triaged by the team labels Sep 2, 2021
@jelbourn
Copy link
Member

jelbourn commented Sep 2, 2021

cc @mmalerba

@mmalerba
Copy link
Contributor

mmalerba commented Sep 2, 2021

The floating label is a known issue that we have a PR for here: #23005, we're just trying to resolve some presubmit issues in google3 so we can get it in.

The fact that the form-field doesn't resize in response to the font size is actually WAI. The old version of form-field extrapolated from the spec to support that, but it was never a real thing in the spec. The spec has since added support for density which is the officially supported way to change the height of the form-field (you can use @include mat.mdc-form-field-density(...) to change it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/form-field G This is is related to a Google internal issue P2 The issue is important to a large percentage of users, with a workaround
Projects
None yet
Development

No branches or pull requests

3 participants