Lots of people seem to have this issue but I haven't found a solution that doesn't create problems in other areas.
How to customize mat-select dropdown position?
.cdk-overlay-pane {
position: absolute;
pointer-events: auto;
box-sizing: border-box;
z-index: 1000;
display: flex;
max-width: 100%;
max-height: 100%;
transform: none !important;
margin-top: 30px;
}
This one works great. ...except that it also affects mat-autocompletes, and not in a good way. It lines up the mat-select options perfectly, and moves the mat-autocomplete options down 30px. Not good.
So I thought, maybe isolate the css to mat-select somehow. There are no parent classes unique to mat-select, so anything :child won't work. There is a direct child class though called mat-select-panel-wrap
. So I looked for a way to access the parent via this unique child. :has is the only thing I found that claims to do this, but alas, zero browser support.
Back in 11 and earlier, Angular Material had a great overlayDir: CdkConnectedOverlay;
that allowed for changes to the options box positioning. But they depreciated it and then made it protected, without fixing the problem that was making people use it in the first place. And their "solution" was "try our experimental mat-select." That solution is dubious at best.
MatSelect overlayDir now private when updating from Angular 11 to 12. How do I access it now?
My question is, does anyone know of a way to isolate the above css to just mat-selects? Or more specifically, to just the mat-select options box.