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

selectedItem momentarily becomes undefined when selection changes.

Open tommycli opened this issue 8 years ago • 2 comments

Description

selectedItem property momentarily becomes undefined when the selection changes. This fires computed bindings.

Expected outcome

selectedItem directly changes from 'before' to 'after', or doesn't fire computed bindings in between.

Actual outcome

The computed binding is fired with selectedItem === undefined.

Live Demo

http://jsbin.com/zidelanake/1/edit?html,js,console,output

Steps to reproduce

  1. Load the live demo
  2. Click the "Next" button in the Output pane
  3. Observe the Console.

Actual: "getSelectedItemId result: one" "getSelectedItemId result: undefined" "getSelectedItemId result: two"

Expected: "getSelectedItemId result: one" "getSelectedItemId result: two"

Browsers Affected

Chrome, though I imagine it affects others also.

tommycli avatar Apr 11 '16 21:04 tommycli

#120 is a potential fix for this; it still needs some clean up though.

bicknellr avatar Jun 09 '16 22:06 bicknellr

Any progress on getting this fixed? When a selectedItem changes not getting the previousValue on the change handler is very frustrating.

I've traced the issue to https://github.com/PolymerElements/iron-selector/blob/master/iron-selection.html#L75-L84 - selectedItem is removed from the selection array and then this gets called https://github.com/PolymerElements/iron-selector/blob/master/iron-selectable.html#L365-L367 - which is then empty cause the selectedItem was removed in the previous function.

chiefcll avatar Jun 23 '17 18:06 chiefcll