PolymerElements / iron-selector

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

Items do not update properly after 'attached' #105

Closed cpboyd closed 8 years ago

cpboyd commented 8 years ago

With paper-menu, I've tried adding paper-items to the menu after creation to no avail.

If the iron-selector could automatically update its item list, then it would be possible to utilize a JSON array (and a dom-repeat) to initialize an iron-selector element's items.

notwaldorf commented 8 years ago

How are you adding your elements? This definitely works: http://jsbin.com/pusoja/1/edit?html,output You need to make sure that you're using Polymer.dom(yourMenu).appendChild(newItem) instead of regular DOM methods, since the correct observers need to fire.

Closing, as this is working. Please re-open if you still have issues, and provide a JSBin with reproducible steps for your problem

cpboyd commented 8 years ago

@notwaldorf

I just realized that it seems the issue is more that paper-menu needs to override iron-selector's default functions, since paper-menu nests content within a div.

Polymer.dom(node).observeNodes() doesn't seem to monitor a child's children.

I've modified a behavior to account for this: https://github.com/cpboyd/paper-menu-input/blob/master/paper-menu-input-behavior.html

By doing this, I'm able to easily add paper-items to the menu/menubar from a JSON array.

notwaldorf commented 8 years ago

If you mean that iron-selector only tracks immediate children, then yes, you're right; this is being tracked in https://github.com/PolymerElements/iron-selector/issues/42. :)

cpboyd commented 8 years ago

Ah. Thanks for that reference.

notwaldorf commented 8 years ago

No worries!