Commit 5ec92cdd authored by Robert Lyon's avatar Robert Lyon

Bug 1568613: Allow keypress to delete a selected option in select2

So that it is more keyboard accessible

behatnotneeded

Change-Id: I7dd437ae6cc4a70e6817fad570df884b5f8b12cb
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 4e75d877
......@@ -22,4 +22,5 @@ Changes:
* Keep focus position when loading more elements with infinite scrolling
* Add label to "Remove tag" button
* Make "Remove tag" button work with the keyboard
* Adding the 'aria-hidden="true"' to presentation icons
\ No newline at end of file
* Adding the 'aria-hidden="true"' to presentation icons
* Adding ability to remove tag via 'enter' key if one is focused on the 'x' of a tag
\ No newline at end of file
......@@ -5313,7 +5313,19 @@ S2.define('select2/core',[
if (key === KEYS.ENTER || key === KEYS.SPACE ||
(key === KEYS.DOWN && evt.altKey) &&
$(evt.target).hasClass('select2-selection')) {
var $remove = $(evt.target).closest('.select2-selection__choice__remove');
if ($remove.length) {
var $selection = $remove.parent();
var data = $selection.data('data');
self.trigger('unselect', {
originalEvent: evt,
data: data
});
}
self.open();
evt.preventDefault();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment