Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select doesn't accept an array value #7584

Closed
tchandelle opened this issue Oct 6, 2017 · 5 comments · Fixed by #7603
Closed

Select doesn't accept an array value #7584

tchandelle opened this issue Oct 6, 2017 · 5 comments · Fixed by #7603
Assignees

Comments

@tchandelle
Copy link
Contributor

tchandelle commented Oct 6, 2017

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

@willshowell
Copy link
Contributor

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

@tchandelle
Copy link
Contributor Author

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

@willshowell
Copy link
Contributor

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

cc @crisbeto

@crisbeto crisbeto self-assigned this Oct 6, 2017
@crisbeto
Copy link
Member

crisbeto commented Oct 6, 2017

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 crisbeto added the has pr label Oct 6, 2017
crisbeto added a commit to crisbeto/material2 that referenced this issue Oct 6, 2017
Fixes not being able to preselect an array if a select is in single selection mode due to an assumption that an array value means that we're in mutliple selection mode.

Fixes angular#7584.
andrewseguin pushed a commit that referenced this issue Oct 9, 2017
…#7603)

Fixes not being able to preselect an array if a select is in single selection mode due to an assumption that an array value means that we're in mutliple selection mode.

Fixes #7584.
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants