material icon indicating copy to clipboard operation
material copied to clipboard

Allow duplicate md-option values in a select.

Open JDGoldman opened this issue 10 years ago • 8 comments

Presently, duplicate md-option values are not allowed in an md-select (line 688 of src/components/select/select.js). I have a scenario where I am populating a select list with duplicate values deliberately, and I would like to have an option to allow duplicate values if we specifically want them without an error being thrown. Perhaps a new attribute on the md-select directive?

JDGoldman avatar Mar 11 '16 19:03 JDGoldman

This would go against the design specs of the component as can be seen here: https://www.google.com/design/spec/components/menus.html#menus-behavior

david-meza avatar Mar 11 '16 20:03 david-meza

Obviously, don't want to go against the design spec (by the way, your link seems to point to something else), but all I am talking about is a way to suppress the error message so my console (and the user's console) isn't littered with unnecessary messages.

Also, it is not a menu item, but a select list used to filter a search -- I have duplicate Ids for items which appear different in the list but go to the same filter (product categories: Vests and Tops -> Vests -- both have the same CategoryID value but their text display is different).

JDGoldman avatar Mar 11 '16 22:03 JDGoldman

I think value works like a id here. so It needs to be unique and as long its unique you can select that item.

Nextt1 avatar Mar 12 '16 20:03 Nextt1

The link was right. This part, in particular, is what I was referring to:

2016-03-12_16-02-37

Have you considered using a md-optgroup label for broader categories?

david-meza avatar Mar 12 '16 21:03 david-meza

Thank you for the link, and the photo. I did find it finally. It is not really applicable because what shows up for the user is, for example, Vests on the one hand, and Tops --> Vests on the other hand. I don't want to use an option group because the idea is we have about 100 categories and sub-categories and somebody may be looking for Vests and not realize that the Vests are actually a sub-category of Tops. Tops and Vests appear about 20 items in the list apart from each other so a user may not see them together, hence the need to make it easier for my users to find the categories they want (and the duplicate values). The md-select works fine, it just emits an error because of the duplicate Ids. I want to suppress the error.

JDGoldman avatar Mar 12 '16 23:03 JDGoldman

In general, I agree that each id should be unique. We will leave this open, but with a low priority. If it gets enough votes, we will consider adding it.

topherfangio avatar Mar 16 '16 20:03 topherfangio

This issue is closed as part of our ‘Surge Focus on Material 2' efforts. For details, see our forum posting @ http://bit.ly/1UhZyWs.

ThomasBurleson avatar Jun 02 '16 07:06 ThomasBurleson

+1

amritk avatar Jun 29 '16 23:06 amritk