So this is the default behaviour of mat-select(selected option opens directly) and this is what my code gives because I enclosed the mat-option fields inside a div tag(for styling purpose)
Below is my code
component.html
<mat-select [(value)]="selectedGroup" class="text-head" required panelClass="headerPanel">
<mat-form-field *ngIf="groupList.length>4" class="organistation-searchField" appearance="outline">
<input (keydown)="$event.stopPropagation()" [(ngModel)]="searchTerm" matInput (ngModelChange)="_globals.dropdownSearch($event,'group_list','headerPanel')" placeholder="Search Zone">
<mat-icon matSuffix style="color:#24539f;">search</mat-icon>
</mat-form-field>
<div class="panel-optn" style="max-height:190px;">
<mat-option class="group_list" *ngFor="let group of groupList" [value]="group.group_id">
{{group.name}}
</mat-option>
</div>
</mat-select>
component.css
.panel-optn{
overflow-y: auto;
scrollbar-color: slategrey rgba(0,0,0,0.3); /* thumb and track color */
scrollbar-width: thin;
}
.panel-optn::-webkit-scrollbar {
width: 0.5em;
}
.headerPanel{
position: relative;
top: 40px;
overflow-y: hidden !important;
left: -8%;
max-width: 235px !important;
}
Using the panel-optn class on mat-select and removing the div tag solves the problem. But I can't do that because then the search bar won't be fixed to the top. Is there a way to bring the default behaviour back?