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

Selected element not updated when DOM elements are reordered #130

Open
sklobovskaya opened this issue Jul 27, 2016 · 0 comments
Open

Selected element not updated when DOM elements are reordered #130

sklobovskaya opened this issue Jul 27, 2016 · 0 comments

Comments

@sklobovskaya
Copy link

sklobovskaya commented Jul 27, 2016

Description

When the selectable elements in an iron-selector are reordered, the selected element is not updated.

Demo and steps to reproduce

http://jsbin.com/huyupeh/edit?html,js,output

  1. Open the demo above, which contains an iron-selector and a dom-repeat inside, which generates a list of selectable items from an array, using attrForSelected to identify each item's value.
  2. Click the 'Change order' button. This will reset the dom-repeat array with a brand new list of items, containing the same number of items with the same values, but in a different order.
  3. Observe the currently-selected item in the list.

Actual outcome

The second item in the list remains selected even as the order of the items is changed and the second item's value is now "four", not "two".

Expected outcome

The item with the name "two" should be selected, since the selected value "two" did not change and there is still a valid item with this value in the list.

I believe this is happening because a simple re-ordering of the dom-repeat array only results in the attrForSelected attribute values being updated, with no DOM nodes being added or removed, so updateItems/updateSelected is not called.

@sklobovskaya sklobovskaya changed the title Selection not updated when DOM elements are reordered Selected element not updated when DOM elements are reordered Jul 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant