components
components copied to clipboard
feat:(angular/component): Configurable reversion value for requireSelection for MatAutocomplete
trafficstars
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