-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
The label on a mat form field with Outline with a prefix not aligning inside a dialog #15027
Comments
Same problem here |
I encountered the same issue. It can be reproduced with the Dialog example form the official Angular Material website.
If lazy, use this stackblitz :) |
@mmalerba is this addressed by one of the open form-field PRs? |
I don't think so, there's an open one for a similar issue with RTL (#15415), but I don't think its related to this one |
When using embedded view from a prepared TemplateRef, the same issue appears <ng-template #prefixRef>
<button mat-icon-button *ngIf="switch">
<mat-icon>check</mat-icon>
</button>
<mat-icon *ngIf="!switch">check</mat-icon>
</ng-template>
<p>
<mat-form-field appearance="outline" floatLabel="always">
<mat-label>Outline form field</mat-label>
<ng-container matPrefix [ngTemplateOutlet]="prefixRef"></ng-container>
<input matInput placeholder="Placeholder" />
<mat-icon matSuffix>
{{ switch ? 'sentiment_very_dissatisfied' : 'sentiment_satisfied' }}
</mat-icon>
<mat-hint>Weird behavior</mat-hint>
</mat-form-field>
</p> Example on stackblitz.com |
Seeing what I think may be the same issue here. The outline is initially correct, but when mobile device orientation is changed (e.g. landscape -> portrait), changing the width of the input, the outline will overlap the label text. |
Setting a fixed width globally on |
Any update about this? |
Add reference to your mat field like #outlineFieldRef in mat-form-field tag Then call this function based on your use case -> updateOutlineGap() |
any updates on this issue? |
@farah111 @abannsunny you can work around the problem using the fix provided by @shubhamseth29 above. Add the following to the
|
We have seen the same issue, are there any updates on when it would be fixed ? Angular version: 10.1.0 |
@marlinverhulst facing the same issue here, and on the same versions. |
Same issue here using just a standard mat-input inside a mat-form-field...no prefix or suffix and the label aligns all the way to the left while the opening for it in the outline is near the center of the input. No styling applied at all...this is just out-of-the-box functionality. Definitely shouldn't have to rely on running something in a settimeout method to fix an issue. The material.angular.io website is displaying it correctly...not sure how they're doing that. |
Same issue here, just the default mat select. Please respond with a better solution than a timeout fix... |
The baseline of all the text gets misaligned when using outline and prefixes, as well. |
@avinashkgit That seems to a completely different issue, not related to this one. |
I have met the same issue, solved by using |
Hi Team do we have any fix for this issue, Same issue persist with Angular Material 11.2.1. I tried P.S. settimeout don't seens to be a valiid solution. Dependencies Dev Env. |
This solves my issue. Thank you. First, set floatLabel to always : { provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { floatLabel: 'always' } }, Then, import This label was misaligned and it's fix now |
The problem with my "solution", is that |
Confirmed simply importing |
Hi, I added a small piece of css and it seems to do the trick:
|
This is the workaround I am using, note if you don't have a dialog component (e.g. you are just using a template) you can also do: @ViewChildren(MatFormField) formFields: QueryList<MatFormField>;
const dialogRef = this.dialog.open(templateRef);
dialogRef.afterOpened().subscribe(() => {
this.formFields.forEach(formField => {
formField.updateOutlineGap();
});
}); |
There are two workarounds for a custom font case: First workaround:
Second workaround:
|
Seems to be fixed in mdc. Works correctly after upgrading to v15 |
Confirmed that this is fixed with the latest version: https://stackblitz.com/edit/angular-vsud9k |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug:
Form-Field-Outline-Label-Gap does not reposition correctly when it is opened in a dialog and the Form-Field has a prefix.
This bug still exists in the latest version
there is an existing issue which is closed:
#13769
What is the expected behavior?
The Form-Field-Outline-Label-Gap should be positioned correctly with or without a prefix. Inside a dialog.
What is the current behavior?
The Form-Field-Outline-Label-Gap does not reposition itself away from the form field prefix like the label does when it is opened in a dialog.
What are the steps to reproduce?
I edited the stackblitz
https://stackblitz.com/edit/form-field-outline-label-gap-position-error-in-dialog
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular 7.2.3
Angular Material 7.0.3
chrome: 71
The text was updated successfully, but these errors were encountered: