Open mbsh-code opened 10 months ago
@mbsh-code Hi. Could you provide stackblitz ??
Same here. I have a dialog with 9 Angular Material form fields. The last 4 do not float the label when there is data to repopulate for them when the FormGroup is created. All the other fields with masks are fine.
When the problematic fields are empty and you add data, they behave fine. When you click into any field, all the labels float up.
All 9 of my fields are currency fields and have the following mask parameters: mask="separator.2" matInput prefix="$" thousandSeparator="," [leadZero]="true"
All my problematic fields are inside a ngFor loop.
When I remove the other (nonproblematic fields) the ones in the loop still have the issue.
The 4 problematic fields are inside a FormGroup inside a FormArray inside the main FormGroup.
The loop is inside an
Fields placed after (below) the looped fields and after the Programmatically setting focus to any of the 4 problematic fields makes all their labels behave fine. Also, removing the looped fields completely, but keeping the last field inside the It does not fix it if I remove the thousandSeparator or prefix or [leadZero]
It does not fix it if my mask is set to "000" or "99999999" Angular: 16.2.12
Angular Material: 16.2.12
ngx-mask: 16.4.2 In summary, the labels do not float when:
1) Inside an HTML element with an ngIf
2) Inside a FormGroup inside a FormArray inside the main FormGroup (rendered with an ngFor) @mbsh-code Hi. Could you provide stackblitz ?? Unfortunately, I cannot do this
My problem also occurs when the inputs are in a formGroup and are created with a loop Same here. I have a dialog with 9 Angular Material form fields. The last 4 do not float the label when there is data to repopulate for them when the FormGroup is created. All the other fields with masks are fine. When the problematic fields are empty and you add data, they behave fine. When you click into any field, all the labels float up. All 9 of my fields are currency fields and have the following mask parameters: mask="separator.2" matInput prefix="$" thousandSeparator="," [leadZero]="true" All my problematic fields are inside a ngFor loop. When I remove the other (nonproblematic fields) the ones in the loop still have the issue. The 4 problematic fields are inside a FormGroup inside a FormArray inside the main FormGroup. The loop is inside an that has an *ngIf. Fields placed after (below) the looped fields and after the are fine. Fields placed after (below) the looped fields, but INSIDE the also show the issue. Fields placed after (below) the looped fields, but INSIDE the WITHOUT the *ngIf are fine. Changing the to a makes no difference.
Removing the still has the 4 fields in a loop being problematic (and the field after is fine).
Programmatically setting focus to any of the 4 problematic fields makes all their labels behave fine. Also, removing the looped fields completely, but keeping the last field inside the It does not fix it if I remove the thousandSeparator or prefix or [leadZero] It does not fix it if my mask is set to "000" or "99999999" Angular: 16.2.12 Angular Material: 16.2.12 ngx-mask: 16.4.2 In summary, the labels do not float when: I have the same problem
My version is the last version published In my case, I have a I got around it by adding Hope this helps! Yeah, we are floating the label always now as a work-around. But I don't want it to float when there is no data.
<mat-form-field>
with a <mat-label>
and an <input>
. When I added the showMaskTyped
attribute on my input, I got the same issue where my mat-label and the mask type were both showing over eachother.floatLabel="{{this.showMaskTyped ? 'always' : 'auto'}}"
to my <mat-form-field>
. I have this.showMaskTyped
coming in dynamically which is why I have the variable. If you are making the form fields manually, you could just add a floatLabel="always"
. Setting this to always will cause the label to begin and stay floating above the input. My <mat-form-field>
opening tag looks like the following:<mat-form-field floatLabel="{{this.showMaskTyped ? 'always' : 'auto'}}">
we have a problem when using mask in input component ، the problem is that title of input and mask interference together we are using angular material version 16.2.0 and angular version is also 16.2.0 and our input of forms generated dynamically how to fix issue? Thanks