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

iron-select event is not always fired because dom-repeat recycles nodes #154

Open
1 of 8 tasks
justincy opened this issue May 4, 2017 · 3 comments
Open
1 of 8 tasks

Comments

@justincy
Copy link

justincy commented May 4, 2017

Description

The iron-select event is not always fired when using dom-repeat to list items because dom-repeat recycles DOM nodes. Say we have a list where the first item is selected. Then we unshift an item to the front of the list. The DOM contents are changed but the DOM nodes are reused. No change is detected because selectedItem in the iron-selectable behavior is pointing to the recycled DOM node.

Related to #130 and solvable by Polymer/polymer#4363

Expected outcome

Either the selection changes to remain in the first position and a iron-select event is fired or the first item remains selected when bumped to the second position.

Actual outcome

No change events are emitted.

Live Demo

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

Steps to reproduce

  1. Select the first item in a list
  2. Unshift an item onto the list

Browsers Affected

Likely all browsers but I only tested Chrome.

  • Chrome
  • Firefox
  • Safari 9
  • Safari 8
  • Safari 7
  • Edge
  • IE 11
  • IE 10
@justincy
Copy link
Author

justincy commented May 4, 2017

As a work around you can force the selection to change to a different item then return it to the original item, but you'll have to be prepared to handle simultaneous change events. For example:

list.selectIndex(1);
list.selectIndex(0);

@amouratoglou
Copy link

amouratoglou commented Jan 24, 2020

hey guys, hope all is good,
same problem around here... did you find a better way to manage this issue?
i´m on Polymer 2.x

@justincy
Copy link
Author

@amouratoglou I'm not aware of any other way.

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

2 participants