-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Description
Bug, feature request, or proposal:
MatSelectionList publically exposes its selection model, but if you try to select an item from the outside it does not update the UI.
What is the expected behavior?
If I call matSelectionList.selectedOptions.select(option)
with an existing option I expect that option to become checked in the UI.
OR the exposed selection model should be some kind of new read-only model. Or at the very least documented as being effectively read-only.
What is the current behavior?
It is not checked. Looking at the source it's obvious why - it doesn't call any change handler.
What are the steps to reproduce?
This sample listens to selection change events and atempts to deselect all items in a selection list before reselecting the one you just clicked (i.e. to simulate a single selection list). If you call MatListOption.selected=true
then it does get updated - but if you call selectedOptions.select(option)
it doesn't.
https://angular-i3pfu2-f3hkj5.stackblitz.io
What is the use-case or motivation for changing an existing behavior?
Confusing. I expect to be able to set an option in the selection model
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
5.2.4 / 5.2.0
Is there anything else we should know?
This particular example was to achieve a single selection model which SelectionModel does natively support, so I don't know why this control doesn't do it.
The ability to select by value seems to be missing too.
Also the ability to hide the checkbox would be nice and show a highlighted background instead.