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
{{ message }}
Repository navigation
[MdListOption] value always boolean, selectChange/deselected events don't fire #6864
The items visually update when being clicked on and off.
The MdSelectionList's selectedOptions variable updates properly.
The selectChange and deselected EventEmitters are never activated.
Which versions of Angular, Material, OS, TypeScript, browsers are affected?
Angular Material 2.0.0-beta.10
Is there anything else we should know?
Looking at the current code, it looks like they aren't ever used or references apart from their declarations.
The focus and destroyed events seem to emit fine though.
Also the value variable for MdListOption is coerced to a boolean value so even using selectedOptions doesn't make the MdListOption useable.
Reacted by Gabriel Boudreau, Sam Dornan, Simon Jackson and David Gonzalez
If it's intended to work like checkboxes, the value will always be a boolean. The actual value would be accessible via the selectChange method's $event.
Edit: No, it's not like this. I get a little bit confused with this once in a while: if you bind a component variable to ngModel, it get the checkbox state instead of it's value. Nothing to do to what is being passed to onChange observer method.
I've also noticed that when a MdListOption is already selected when it initially loads (has an @input [selected]="true") then its MdSelectionList.selectedOptions.selected are incorrectly populated, i.e. it seems to add the options to the selected list when it is clicked and becomes deselected.
@dereekb Have you noticed anything similar and is the issue I'm describing something that will be fixed with the changes in you PR?
@glampr I do recall running into that issue come to think of it and don't think there is a unit test for that case.
In my case I was already making a specific controller/wrapper for MdSelectionList so I worked around it by setting the values after they were added to the views to avoid running into that issue, but initially I did try to set selected through the *ngFor loop and initially selected items weren't working like you described.
When I get a chance I'll add a new unit test to test against it. Is there a bug report for it?
Activity
julianobrasil commentedon Sep 6, 2017
A plunk is always useful: https://plnkr.co/edit/6y5tPM?p=preview
dereekb commentedon Sep 6, 2017
Thanks! I updated your plunk to show the two issues, the second issue being all values being coerced to a boolean.
https://plnkr.co/edit/hfo1kUlv7zxGioL1y72C?p=preview
The second issue probably belongs in it's own bug report, but its a 1 line fix in selection-list.ts:
The EventEmitter fix is also straight forward:
When I get a chance (and figure out how) I'll submit a pull request for that/those fixes.
julianobrasil commentedon Sep 6, 2017
If it's intended to work like checkboxes, the value will always be a
boolean. The actual value would be accessible via theselectChangemethod's$event.Edit: No, it's not like this. I get a little bit confused with this once in a while: if you bind a component variable to ngModel, it get the checkbox state instead of it's value. Nothing to do to what is being passed to onChange observer method.
dereekb commentedon Sep 6, 2017
Yea, I think someone just made a copy/paste typo/error. The value's type is set to "any" but it gets coerced just like the setter below it:
As I said before this is a separate issue that probably belongs in it's own bug report since it effectively makes the Selection List a checkbox.
I'll make a pull request when I get a chance, unless someone else beats me to it.
[-][MdListOption] selectChange/deselected events don't fire[/-][+][MdListOption] value always boolean, selectChange/deselected events don't fire[/+]glampr commentedon Sep 18, 2017
I've also noticed that when a MdListOption is already selected when it initially loads (has an @input [selected]="true") then its MdSelectionList.selectedOptions.selected are incorrectly populated, i.e. it seems to add the options to the selected list when it is clicked and becomes deselected.
@dereekb Have you noticed anything similar and is the issue I'm describing something that will be fixed with the changes in you PR?
dereekb commentedon Sep 18, 2017
@glampr I do recall running into that issue come to think of it and don't think there is a unit test for that case.
In my case I was already making a specific controller/wrapper for MdSelectionList so I worked around it by setting the values after they were added to the views to avoid running into that issue, but initially I did try to set selected through the *ngFor loop and initially selected items weren't working like you described.
When I get a chance I'll add a new unit test to test against it. Is there a bug report for it?
glampr commentedon Sep 19, 2017
@dereekb as far as I can tell there is no bug report for this.
Do you want me to create a separate issue?
dereekb commentedon Sep 19, 2017
Yea, I think that would be a good idea since this issue has been resolved.
glampr commentedon Sep 19, 2017
@dereekb created issue #7183 just in case you want to follow it.
josephperrott commentedon Sep 27, 2017
Closing as this issue is resolved as noted above.
fix(selection-list): fix option value coercion and selection events (#…
angular-automatic-lock-bot commentedon Sep 7, 2019
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.