iron-list icon indicating copy to clipboard operation
iron-list copied to clipboard

iron-list doesn't restore template when element gets recycled

Open ronnyroeller opened this issue 9 years ago • 2 comments

Description

I use iron-swipeable-container in an iron-list. Swiping an item removes the DOM node within the iron-list entry. Setting afterwards new data fails to restore the deleted DOM node.

This does work with dom-repeat (see live demo: https://jsbin.com/cakizohagu/edit?html,output).

Expected outcome

DOM node should be restored according to the template in the iron-list.

Actual outcome

Data isn't visible (since the entry in the list doesn't have any longer the DOM node to show the data).

Live Demo

https://jsbin.com/cakizohagu/edit?html,output

Steps:

  1. Open live demo
  2. Swipe away item "B" from the first block (iron-list) => Now item "C" isn't any longer visible in the iron-list (but still visible in the dom-repeat list)
  3. Click on button "Reset items" => Item "B" is still not visible in iron-list (but is correctly visible in dom-repeat list)

Steps to reproduce

See JSBin

Browsers Affected

  • [X] Chrome
  • [X] Firefox
  • [X] Safari 9

ronnyroeller avatar Jul 03 '16 22:07 ronnyroeller

This issue looks similar to https://github.com/PolymerElements/iron-list/issues/257

ronnyroeller avatar Jul 03 '16 22:07 ronnyroeller

Yes, it's the same issue. In this case, iron-swipeable-container removes the element from the light DOM. https://github.com/PolymerElements/iron-swipeable-container/blob/master/iron-swipeable-container.html#L257

Because the DOM was removed dynamically, those nodes can't be recycled, but iron-list is not aware of those changes. I wonder if iron-swipeable-container could trigger an event when it's about to remove the DOM and do nothing if the event is defaultPrevented. That way we could fix this issue. cc @notwaldorf

blasten avatar Jul 06 '16 23:07 blasten