Skip to content

mat-select does not display default (null) option text in mat-option #25120

Closed
@zolakt

Description

@zolakt

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

I'm reposting this issue again: #6466

since you closed it without providing any reasonable workaround or an explanation why you chose to implement this super weird, opinionated, behaviour. What is the reason to implement it like this? What problems does you implementation solve or prevent? From what I can see, it's just limiting a very common use-case, without any reasonable benefits. If you really insist on this, at least make it optional with an input binding, so we can opt-out of it when we don't need it.

The only workaround for this is to use some other value, e.g. '' and then map it back and forth all over the place, for each mat-select. Honestly this is ridiculous. Totally messy, bug prone etc. and still a very poor workaround.

I haven't found a single workaround that would enable the desired behaviour in the use-case when you have your own component, implementing control value accessor, which wraps a mat-select.

Reproduction

http://plnkr.co/edit/i919jzNOoXhlPeN4hxxE?p=preview

Expected Behavior

Select should display text associated with null/undefined value when provided

Actual Behavior

Select displays nothing

Environment

  • Angular: 14,0,0
  • CDK/Material: 14.0.0
  • Browser(s): ALL
  • Operating System (e.g. Windows, macOS, Ubuntu): ALL

Metadata

Metadata

Assignees

Labels

P4A relatively minor issue that is not relevant to core functionsarea: material/selectneeds: discussionFurther discussion with the team is needed before proceeding

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions