components icon indicating copy to clipboard operation
components copied to clipboard

Select doesn't accept an array value

Open tchandelle opened this issue 9 years ago • 5 comments

Bug, feature request, or proposal:

Bug

What is the expected behavior?

Should be able to set an array as the value of a select

What are the steps to reproduce?

https://plnkr.co/edit/lnj292JDLrd2SS0cPzNo?p=preview In select-overview-example.ts, see lines 19 and 20. When the preselected value is an array, it doesn't work.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Since, at-least, beta.8. Still in beta.12 Angular 4.4.4

tchandelle avatar Oct 06 '17 12:10 tchandelle

Please see compareWith. By default MatSelect compares values by Object reference.

willshowell avatar Oct 06 '17 13:10 willshowell

That's not the problem. I pass the same array with the same reference. Looking at the sources, I think the problem is on select.ts:722. It should check this.multiple instead of isArray

tchandelle avatar Oct 06 '17 14:10 tchandelle

Ah my bad! There have been lots of questions like that lately, so I didn't fully look it over.

cc @crisbeto

willshowell avatar Oct 06 '17 14:10 willshowell

The assumption has always been that if you're providing an array value, you're probably in multiple mode, but I see how it's an issue.

crisbeto avatar Oct 06 '17 16:10 crisbeto

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.