Skip to content

help(MatSelect): MatSelect .cdk-overlay-pane fixed width with Angular Material 15 #26336

Closed
@Raphyyy

Description

@Raphyyy

What are you trying to do?

I am trying to migrate a large app using Angular Material to v15 and like many of us I have to overwrite some default styles on Angular Material components.

I am facing an issue with the new MatSelect v15. It seems that now the default behavior is to make the overlay-pane use the exact same width as its mat-select related component, directly by setting the width to the element (.cdk-overlay-pane) styles.
If the mat-form-field or mat-select have a small width, the mat-option texts get word wrapped and it is pretty ugly :

https://stackblitz.com/edit/angular-sbq67h?file=src/app/select-overview-example.html

Is there any way I could prevent this fixed width on the related .cdk-overlay-pane for my mat-select component ?

What troubleshooting steps have you tried?

Adding white-space: nowrap; to .mat-mdc-option .mdc-list-item__primary-text prevent the wrapping issue but the .cdk-overlay-pane fixed width do not allow any overflow. The @input panelClass can't help because .cdk-overlay-pane is a parent.

Reproduction

Steps to reproduce:

  1. https://stackblitz.com/edit/angular-sbq67h?file=src/app/select-overview-example.html

Environment

  • Angular: 15.0.4
  • CDK/Material: 15.0.4
  • Browser(s): Google Chrome v108
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10

Metadata

Metadata

Assignees

Labels

needs triageThis issue needs to be triaged by the teamtroubleshootingThis issue is not reporting an issue, but just asking for help

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions