You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I listen to change events of the MatSelectionList and I use selectedOptions.selected to know the current selected values, they are not always up to date.
Problem lies in Selection.ts#125:
The onChange.next is called, before the cached value of _selected is reseted.
Therefore the get selected() will return the old value.
The bug only seems to occure, if you first set a value of another material-component, so it might be a timing-problem.
What is the expected behavior?
The cached value of _selected should be reset, so that I get the current value in onChange.
What is the current behavior?
When calling selectedOptions.selected, I sometimes get the previous value.
What are the steps to reproduce?
Create a Angular-Material application with a MatSelectionList. You might need another component (for example an input) too, to reproduce the bug.
Add an onChange-Listener to the MatSelectionList and console.log the value of selectedOptions.selected.
Focus the input (or any other material component in your app).
Select one of the MatListOptions inside the MatSelectionList and look at the value in the console.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
I am using @angular/material and @angular/cdk version 5.0.0-rc0 as well as @angular version 5.0.1
Is there anything else we should know?
A simple window.setTimeout(() => console.log(selectedOptions.selected)) seems to solve the problem.
The text was updated successfully, but these errors were encountered:
…ge subscription
Fixes the `selected` value being out of date in the `SelectionModel`, if it is accessed inside an `onChange` subscription.
Fixesangular#8584.
…ge subscription (#8599)
Fixes the `selected` value being out of date in the `SelectionModel`, if it is accessed inside an `onChange` subscription.
Fixes#8584.
Bug, feature request, or proposal:
When I listen to change events of the
MatSelectionList
and I useselectedOptions.selected
to know the current selected values, they are not always up to date.Problem lies in Selection.ts#125:
The
onChange.next
is called, before the cached value of_selected
is reseted.Therefore the
get selected()
will return the old value.The bug only seems to occure, if you first set a value of another material-component, so it might be a timing-problem.
What is the expected behavior?
The cached value of
_selected
should be reset, so that I get the current value inonChange
.What is the current behavior?
When calling
selectedOptions.selected
, I sometimes get the previous value.What are the steps to reproduce?
onChange
-Listener to theMatSelectionList
andconsole.log
the value ofselectedOptions.selected
.MatListOptions
inside theMatSelectionList
and look at the value in the console.Which versions of Angular, Material, OS, TypeScript, browsers are affected?
I am using @angular/material and @angular/cdk version 5.0.0-rc0 as well as @angular version 5.0.1
Is there anything else we should know?
A simple
window.setTimeout(() => console.log(selectedOptions.selected))
seems to solve the problem.The text was updated successfully, but these errors were encountered: