PolymerElements / paper-dropdown-menu

A Material Design browser select element
https://www.webcomponents.org/element/PolymerElements/paper-dropdown-menu
61 stars 107 forks source link

Observer set for `value` attribute gets fired twice each time an item gets picked #252

Open vedtam opened 7 years ago

vedtam commented 7 years ago

Hi,

Each time I pick an item from the paper-dropdown-menu, the observer which I set for the value attribute gets fired twice, once having the desired value and a second time having null.

Expected outcome

The observer should fire only once / item picked.

Thanks!

screen shot 2017-06-25 at 08 59 29

<paper-dropdown-menu label="pick a category" value="{{category}}" id="categories" style="display: inline;">
  <paper-listbox slot="dropdown-content" class="dropdown-content" selected="{{selectedCategory}}">
    <template is="dom-repeat" items="{{noneEmptyCategs}}">
        <paper-item value={{item.category}}>{{item.category}}</paper-item>
    </template>
  </paper-listbox>
</paper-dropdown-menu>

....

static get properties(){
  return {
    category: {
      type: String,
      observer: 'categorySelected',
      value: ''
    }
  }
}

categorySelected(category){
  console.log('item picked: ' + category);
}
hobbyquaker commented 6 years ago

https://github.com/PolymerElements/paper-dropdown-menu/blob/master/paper-dropdown-menu.html#L354 - I'm asking myself if handling the iron-deselect event is neccessary at all because one can't deselect something in a dropdown?