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

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: default avatarRobert Lyon <robertl@catalyst.net.nz>
parent 4e75d877
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -23,3 +23,4 @@ Changes:
  * Add label to "Remove tag" button
  * Make "Remove tag" button work with the keyboard
  * 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
+12 −0
Original line number Diff line number Diff line
@@ -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();
        }
      }