PolymerElements / iron-selector

Manages a list of elements that can be selected
32 stars 55 forks source link

Proposal for PR: add "traditional" multi-select to iron-selector #123

Open Caffeinix opened 8 years ago

Caffeinix commented 8 years ago

I have written an extension to IronMultiSelectableBehavior that implements a more general and traditional form of multi-select, similar to how multi-select works in most desktop applications. The behavior is as follows:

My implementation is small (43 source lines) and works by extending IronMultiSelectableBehavior and overriding two functions, _activateHandler and _toggleSelected. The _activateHandler implementation just records the keyboard modifiers and then calls IronMultiSelectableBehavior's version. _toggleSelected is where the actual logic is implemented.

My implementation does not support a "mixed" mode where an unmodified tap will toggle the selection state like IronMultiSelectableBehavior, but a shift-click will extend the selection. Such a thing would be relatively easy to add if it were desired, but it would increase the complexity somewhat.

This PR would fix https://github.com/PolymerElements/iron-selector/issues/38.

Thoughts?

bicknellr commented 8 years ago

I think this would be really awesome! We might have to go with the "mixed" mode you mentioned as the default since we'd be introducing a breaking change otherwise, but allowing the regular <select multiple> style wouldn't be a problem if it was behind a property.

yarikus commented 7 years ago

Where I can to get your extension? Please share it with community.

timoteoponce commented 7 years ago

Where can we get a preview of this extension to test it?

czellweg commented 7 years ago

@Caffeinix Awesome, I'd be interested to look at this code as well. Can you share it?