components
components copied to clipboard
fix(material/list): selection list option selected value reset if form control is initialized to empty value
Fixes the selected
value of a mat-list-option
that is set through an input being reset if a FormControl
is assigned to the list with a default empty value.
It looks like there's still an issue where the form control value is out of sync with the selected options after initialization
To clarify, the individual options initialize before the @ContentChildren(MatListOption) options
is initialized. The selected
setter tells the list that it should update its value, but the _reportValueChange
doesn't update the form model because those options
are still undefined
at that point.
We should probably add a subscription on the options
query list that initializes the form state from the options if it hasn't been initialized already.
@jelbourn isn't that what we're doing here in ngAfterContentInit
?
I mean that the SelectionModel
does have the correct values from the selected
property on the options.
Closing since this is quite out of date and we haven't gotten any bug reports about it as far as I can see.
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.