Maps a tap/mousedown on a list item to selection of that item


This simple mixin is useful in list-like elements like ListBox, where a tap/mousedown on a list item implicitly selects it.

The standard use for this mixin is in list-like elements. Native list boxes don't appear to be consistent with regard to whether they select on mousedown or click/mouseup. This mixin assumes the use of mousedown. On touch devices, that event appears to trigger when the touch is released.

This mixin only listens to mousedown events for the primary mouse button (typically the left button). Right clicks are ignored so that the browser may display a context menu.

This mixin expects the component to provide an items property. It also expects the component to define a state.selectedIndex member; you can provide that yourself, or use SingleSelectionMixin.

If the component receives an event that doesn't correspond to an item (e.g., the user taps on the element background visible between items), the selection will be removed. However, if the component sets state.selectionRequired to true, a background tap will not remove the selection.