I have a mat-form-field with a standard input inside of it and a mat-autocomplete attached.
<mat-form-field appearance="fill">
<mat-label>{{ 'INVENTORY.areaOfBusiness' | translate }}</mat-label>
<input type="text" matInput
[matAutocomplete]="businessAreaAuto"
(keyup)="search($event, 'businessArea')"
[(ngModel)]="businessArea">
<mat-icon matSuffix>add</mat-icon>
<mat-autocomplete #businessAreaAuto="matAutocomplete" (optionSelected)="businessSelection($event)">
<mat-option *ngIf="bizNoResults === true" class="no-click">{{ 'INVENTORY.no-result' | translate }}</mat-option>
<mat-option *ngIf="isSearchBiz === true">
<div class="desktop-spinner">
<span>{{ 'INVENTORY.searching' | translate }}...</span>
<mat-progress-spinner
diameter = 20
mode = "indeterminate"
[value]="value">
</mat-progress-spinner>
</div>
</mat-option>
<mat-option
*ngFor="let bizArea of businessAreaResults | async"
[value]="bizArea"
matTooltip="{{bizArea}}">
{{bizArea}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
On the mat-form-field I have added a transition width when the mat-focused class is applied:
mat-form-field {
margin-left: 24px;
font-size: 14px;
width: 170px;
transition: width .5s ease;
}
.mat-focused {
width: 270px;
}
However I am running into issues with the width sizing of the autocomplete panel when the input goes in and out of focus. The autocomplete panel doesn't seem to truly catch up with the proper width until the user is typing in text. I haven't found a method or input in the angular material docs that has a good way to update the autocomplete with the correct size. It seems to be catching the size on the input at different points of the transition process.
Any help/suggestions would be much appreciated
stackblitz https://stackblitz.com/edit/angular-yfxr8y