fabbricadigitale / paper-chip

A chip web component made with Polymer 2 following Material Design guidelines
http://webcomponents.org/element/fabbricadigitale/paper-chip
MIT License
31 stars 16 forks source link

Values not using value-property specified object keys #61

Closed KeithHenry closed 6 years ago

KeithHenry commented 6 years ago

Values will often be object keys, of the same type as the datasource, something like:

<paper-chip-input id="testChipInput"
  values="[1,4]" 
  display-property="name" value-property="id" 
  datasource="[
    {id:1, name:'one'},
    {id:2, name:'two'},
    {id:3, name:'three'},
    {id:4, name:'four'}]"></paper-chip-input>

I would expect this to display two chips with labels "one" and "four", but instead it shows them with no values.

Now suppose I remove those two chips and select "three". That displays as expected, but:

console.log(this.$.testChipInput.values)

Outputs:

[{id:3, name:'three'}]

Given that I have specified an object key with value-property="id" I would expect the values property to be [3].

leodido commented 6 years ago

I have added a demo example covering the pre-filling of a paper-chip-input with autocomplete on.

leodido commented 6 years ago

With upcoming major release values property will contain only values.

You can use it to prefill a paper-chip-input, to retrieve values for your labels and so on.