Open jonboj opened 8 years ago
Sounds similar to dart-lang/polymer_elements#92 Might be an issue with array-selector. I guess this is used for selection of such lists (not sure).
Interesting, this gave me a clue. Debugging into iron-multi-selectable.html
The tap selection from Dartium puts an int 0 into this.selectedValues, but the select method from Dart comes with a String "0" so at this line https://github.com/dart-lang/polymer_elements/blob/master/lib/src/iron-selector/iron-multi-selectable.html#L62 it don't matches and pushes "0" into the array, this gives the two instance. Same index, but different type reprensentations int/String.
------------------------------- Update -------------------------------- With some debugging in the call stacks for the two cases.
In Dartium tap on menu item, the int case.
The tap event from Dartium gets converted to an int value at this location https://github.com/dart-lang/polymer_elements/blob/master/lib/src/iron-selector/iron-selectable.html#L308 For later down the call stack end as value to a select call.
From dart code when PaperMenu.select is called, the String case. At api level https://github.com/dart-lang/polymer_elements/blob/master/lib/iron_multi_selectable.dart#L36
------------------------- _indexToValue -------------------------
Looking at the method _indexToValue
if attrForSelected
isn't set, it just return the index
.
https://github.com/dart-lang/polymer_elements/blob/master/lib/src/iron-selector/iron-selectable.html#L255
If attrForSelected
isn't set value is item, so in _indexToValue
it seems more logic if returned this.items[index];
here:
https://github.com/dart-lang/polymer_elements/blob/master/lib/src/iron-selector/iron-selectable.html#L261
Reproduced with polymer_elements: ^1.0.0-rc.9
From pubspec.yaml
environment:
sdk: '>=1.9.0 <2.0.0'
dependencies:
browser: ^0.10.0
polymer_elements: ^1.0.0-rc.9
polymer: ^1.0.0-rc.17
web_components: '>=0.11.3 <0.13.0'
Environment/Code
A paper-menu with multi selection. Dartium html
dart
What is expected
For a value in
selectedValues
shouldselect
insert and remove the value fromselectedValues
.Actual outcome
First time
select(v)
is called an extra instance ofv
is added into theselectedValues
. This instance remains when the item is deselected with tap from Dartium.Howto reproduce
paper-menu
, with tap from the Dartium browser.select
to deselect the item selected above. E.g. if first thenselect('0')
. This will leave two instances of 0 inselectedValues
.selectedValues
.selectedValues
.console print dumps.
Cut from pub.yaml