PolymerElements / iron-selector

Manages a list of elements that can be selected
32 stars 55 forks source link

_observeItems not called when item # doesn't change #156

Open deto opened 7 years ago

deto commented 7 years ago

Description

I have a <template is="dom-repeat"> inside of an <iron-selector> (actually a <paper-listbox>). If I change the items inside the "dom-repeat" to a new Array, but the new Array has the same number of items as the old Array, the selection doesn't update.

I believe that I have tracked this down to _observeItems (or rather, the callback defined inside it), not firing in this situation.

I ran into this while implementing a cascaded dropdown, whereby the selection in one paper-dropdown-menu influenced the item list in the second.

This is on the latest 1.x iron-selector and Polymer component set so I'm not sure if this has been fixed already in 2.0

Expected outcome

When changing the nodes under iron-selector, _observeItems is run and "iron-items-changed" is fired, even if the list has the same number of elements as before.

Actual outcome

My second paper-menu-dropdown is showing the same selection as before since 'iron-items-changed' never fired.

Live Demo

Steps to reproduce

Create this:

<paper-listbox>
    <template is="dom-repeat" items="[[myItems]]">
        <paper-item data-index$="[[item.Index]]">[[item.Name]]</paper-item>
    </template>
</paper-listbox>

Set this.myItems to [{ Index: 1, Name: 'XX'}] and "iron-items-changed" is fired as expected.

Now set this.myItems to [{ Index: 2, Name: 'YY'}] and "iron-items-changed" is not fired.

Browsers Affected

haoruiqian commented 4 years ago

Any updates on this issue?