问题
I am including form inputs, mat select with options and autocomplete field with options too into a matDialog box. The problem is that the options are showing behind the Dialog. I’ve already came across those solutions solution1 but did'nt solve this problem. here is my code:
<mat-form-field class="wrapField">
<mat-select (selectionChange)="selectChange($event)" formControlName="product" placeholder="Alle Produkte">
<mat-option *ngFor="let product of products" value="{{product.id}}">{{product.nummer}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="wrapTime">
<input matInput placeholder="Startzeit" [formControl]="myControl" [matAutocomplete]="auto" formControlName="startTime" required>
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let option of filteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
et here is the style.css file:
.cdk-global-overlay-wrapper, .cdk-overlay-container {
z-index: 99999 !important;
}
Any ideas how to fix that ?
回答1:
I too had the same issue. As you have found out, this bug is due to the conflicts of z-indices. So I put the following CSS in my global.css
which solved the issue:
.cdk-overlay-container, .cdk-overlay-pane {
z-index: 9999 !important;
}
来源:https://stackoverflow.com/questions/52203275/mat-select-options-showing-behind-the-dialog