Skip to content

feat:(angular/component): Configurable reversion value for requireSelection for MatAutocomplete #31141

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

herrevilkitten
Copy link

Adds a new input for MatAutocomplete: revertValueTo. This input works with requireSelection and allows the developer to provide a value that should be reverted to instead of null. One use case for this feature is to have the autocomplete revert to the last known value instead of null with something like: [revertValueTo]="formControl.value"

This defaults to null in order to maintain backwards compatibility.

The use-case that led to this change is a time zone picker. If the user does not select a time zone, it will revert to either the previously selected time zone or the browser's time zone.

Video using the demo app: https://www.youtube.com/watch?v=cqZ2WzNDZbk

…ection for MatAutocomplete

Adds a new input for `MatAutocomplete`: `revertValueTo`. This input works with `requireSelection`
and allows the developer to provide a value that should be reverted to _instead_ of `null`. One
use case for this feature is to have the autocomplete revert to the _last known_ value instead
of `null` with something like: `[revertValueTo]="formControl.value"`

This defaults to `null` in order to maintain backwards compatibility.

The use-case that led to this change is a time zone picker. If the user does not select a time
zone, it will revert to either the previously selected time zone or the browser's time zone.

Video using the demo app: https://www.youtube.com/watch?v=cqZ2WzNDZbk
@herrevilkitten herrevilkitten requested a review from a team as a code owner May 18, 2025 13:53
@herrevilkitten herrevilkitten requested review from crisbeto and andrewseguin and removed request for a team May 18, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant