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

fix(material/select): add opt-in input that allows selection of nullable options #30142

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

crisbeto
Copy link
Member

@crisbeto crisbeto commented Dec 6, 2024

By default mat-select treats options with nullable values as "reset options", meaning that they can't be selected, but rather they clear the select's value. This behavior is based on how the native select works, however in some cases it's not desirable. These changes add an input that users can use to opt out of the default behavior.

Fixes #25120.

@crisbeto crisbeto added the target: patch This PR is targeted for the next patch release label Dec 6, 2024
@crisbeto crisbeto requested a review from a team as a code owner December 6, 2024 13:28
@crisbeto crisbeto requested review from mmalerba and andrewseguin and removed request for a team December 6, 2024 13:28
@@ -66,6 +66,15 @@ If you want one of your options to reset the select's value, you can omit specif

<!-- example(select-reset) -->

### Allowing nullable options to be selected

By default any options with a `null` or `undefined` value will reset the select's value. This is
Copy link
Contributor

@andrewseguin andrewseguin Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably remove the statement about mimicing native behavior, since I don't think that's the actual case anymore. It's enough to include the first sentence to basically say "this is how we handle null by default"

@andrewseguin andrewseguin added the action: merge The PR is ready for merge by the caretaker label Dec 10, 2024
@crisbeto crisbeto removed the request for review from mmalerba December 10, 2024 20:36
…ble options

By default `mat-select` treats options with nullable values as "reset options", meaning that they can't be selected, but rather they clear the select's value. This behavior is based on how the native `select` works, however in some cases it's not desirable. These changes add an input that users can use to opt out of the default behavior.

Fixes angular#25120.
@crisbeto crisbeto force-pushed the 25120/select-nullable branch from d489620 to 23d28b5 Compare December 10, 2024 20:38
@crisbeto crisbeto merged commit 0296713 into angular:main Dec 10, 2024
18 of 20 checks passed
crisbeto added a commit that referenced this pull request Dec 10, 2024
…ble options (#30142)

By default `mat-select` treats options with nullable values as "reset options", meaning that they can't be selected, but rather they clear the select's value. This behavior is based on how the native `select` works, however in some cases it's not desirable. These changes add an input that users can use to opt out of the default behavior.

Fixes #25120.

(cherry picked from commit 0296713)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: material/select target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mat-select does not display default (null) option text in mat-option
2 participants