Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong selected value when use dom-repeat #82

Open
duongphuhiep opened this issue Nov 1, 2015 · 4 comments
Open

wrong selected value when use dom-repeat #82

duongphuhiep opened this issue Nov 1, 2015 · 4 comments
Assignees

Comments

@duongphuhiep
Copy link

I use iron-selector on a dom-repeat a list of item

First I set the selected value to foo then set the list to ["bar", "foo"] and I saw foo is selected as expected. But then, I set the list to ["foo", "rock"], the selected value is always foo, but now the real selected node is rock, not foo. So the selected value is no longer tells the real selected node.

<dom-module id="repeat-list">
    <template>
        <style>
            .iron-selected {
                background: yellow;
            }
        </style>
        <ul>
        <iron-selector selected-items="{{selectedItems}}"
                       attr-for-selected="someAttr"
                       selected="{{valueSelected}}">
            <template id="repeater" is="dom-repeat" items="{{list}}">
                <li some-attr={{item}}>{{item}}</li>
            </template>
        </iron-selector>
        </ul>
        First selected item: <span>{{selectedItems.0}}</span><br/>
        Value selected: <span>{{valueSelected}}</span>
    </template>

    <script>
        Polymer({
            is: "repeat-list",
            properties: {
                list: Array,
                selectedItems: Array,
                valueSelected: {
                    type: String,
                    notify: true
                }
            },
            ready: function() {
                this.valueSelected="foo";

                var _this = this;
                setTimeout(function(){
                    _this.list = ["bar", "foo"]; //ok, foo is selected
                }, 1000);

                setTimeout(function(){
                    _this.list = ["foo", "rock"]; //ko! valueSelected="foo" but "bar" item is selected
                }, 2000);
            }
        });
    </script>
</dom-module>
@hedcet
Copy link

hedcet commented Jan 7, 2016

iron-selector not updates its selection on dom repeat items when data change, i tested it in polymer gmail @ebidel example that app fails to update selected property to child element

@cdata
Copy link
Contributor

cdata commented Jan 30, 2016

Please re-open this issue with a JSBin demonstrating the problem! For more details on filing issues, you can refer to our contributing guidelines.

@cdata cdata closed this as completed Jan 30, 2016
@duongphuhiep
Copy link
Author

Hello,

I demonstrated the problem in plunker:

http://plnkr.co/edit/dqSFV2XQ6x1UjJdm7fFl?p=preview

is it ok? do I have to open a new issue or reuse this one?

@hedcet
Copy link

hedcet commented Feb 11, 2016

👍 you r the bro bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants