PolymerElements / iron-selector

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

iron-selector doesn't select in nested templates #47

Closed fooloomanzoo closed 8 years ago

fooloomanzoo commented 9 years ago

as an example:

image

but it doesn't select and I can't figure out why

Code: http://jsbin.com/zuqato/edit?html,console,output

fooloomanzoo commented 9 years ago

it would look like this image and nothing happens

if i select in the upper template like image

it works: image

Trakkasure commented 9 years ago

In iron-selectable the get items() function queries only the distributed nodes. This would normally take care of it. However, templates embedded within another templates hide it's distributed nodes within the surrounding template. I understand using getDistributedNodes when no selectable attribute is specified. But why not just use querySelectorAll when a selectable attribute is specified?

Trakkasure commented 9 years ago

@fooloomanzii Updated with my fix here: http://jsbin.com/pimazupare/edit?html,console,output

fooloomanzoo commented 9 years ago

Looks great! Thanks

Trakkasure commented 9 years ago

Firefox seems to have a problem with the solution on only one test. What is weird, is I can make the test succeed by setting the selected item in the test itself. (as long as the item is different than the default selected item) This test succeeds in Chrome. I cannot test Safari, the driver won't work.

notwaldorf commented 8 years ago

Closing as a duplicate of https://github.com/PolymerElements/iron-selector/issues/42. Currently iron-selector only looks at immediate children.

yglodt commented 6 years ago

I have a somehow similar issue exposed with this code:

<iron-selector multi attr-for-selected="value" selected-values="{{selectedTimes}}">
    <template is="dom-repeat" items="[[days]]">
        <template is="dom-repeat" items="[[hours()]]" as="ind">
            <div value="[[itemval(item, ind)]]"></div>
        </template>
    </template>
</iron-selector>

Selection works well, the array selectedTimes is changing as expected.

But pre-setting selectedTimes does not mark any item as selected, strangely.