Selectr icon indicating copy to clipboard operation
Selectr copied to clipboard

Double Selections

Open adrian-enspired opened this issue 6 years ago • 1 comments

When creating a multi-select, build calls getSelectedProperties() to set this.selectedValues and this.selectedIndexes. The former works fine; but the latter gets an empty array (because idx has not yet been set on any of the options).

Later, this causes selected values to be added to this.selectedValues again, since select() uses this.selectedIndexes (which, as noted above, is empty at this point) to detect duplicates.


I wasn't sure what the best solution would be for this. My first thought would be to always set selectedValues by looking up options in selectedIndexes, instead of maintaining the two lists separately, but I'm not sure if this would have a negative impact on anything else, so I'm looking for feedback. If this is a practical solution, I can implement and PR.

adrian-enspired avatar Nov 16 '17 16:11 adrian-enspired

Perhaps I am facing a similar problem.

The selectr item is instantiated with data and when I click an option, it returns the option above the one I clicked. It’s caused by the existence of the empty value in the items array at position 0. The received index in the select function is of by one at this point.

reno1979 avatar Sep 26 '18 11:09 reno1979