Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(mat-select): Does not reflect null value #28203

Closed
1 task
inorganik opened this issue Nov 29, 2023 · 2 comments
Closed
1 task

bug(mat-select): Does not reflect null value #28203

inorganik opened this issue Nov 29, 2023 · 2 comments
Assignees
Labels
needs triage This issue needs to be triaged by the team

Comments

@inorganik
Copy link

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

If a form control is set with a null value, mat-select cannot reflect that by displaying the correct mat-option with value set to null, but it works with a native select.

This behavior is important, because for example if you are building form controls for filtering some data displayed in a UI, you must be able to have a state where all controls are empty, and thus nothing is filtered. The null option can display "All" or something similar - indicating to the user that nothing is filtered. e.g.:

<mat-option [value]="null">All</mat-option>

This issue has existed at least as far back as v 14.

Reproduction

StackBlitz link: https://stackblitz.com/edit/4mzrpg?file=src%2Fexample%2Fselect-overview-example.html
Steps to reproduce:

  1. Witness how the mat-select does not display the null option, but the native select does.

Expected Behavior

Mat-select should correctly reflect a null value like a native select

Actual Behavior

Mat-select shows no option selected

Environment

  • Angular: 17.0.0
  • CDK/Material: 17.0.1
  • Browser(s): Chrome latest
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
@inorganik inorganik added the needs triage This issue needs to be triaged by the team label Nov 29, 2023
@crisbeto
Copy link
Member

Duplicate of #25120.

@crisbeto crisbeto self-assigned this Nov 29, 2023
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs triage This issue needs to be triaged by the team
Projects
None yet
Development

No branches or pull requests

2 participants