Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit b19facd

Browse files
committed
Stop propagation when pressing ESC key from dropdown
1 parent af01d52 commit b19facd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/uiSelectController.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ uis.controller('uiSelectCtrl',
437437
_ensureHighlightVisible();
438438
}
439439

440-
if (key === KEY.ENTER) {
440+
if (key === KEY.ENTER || key === KEY.ESC) {
441441
e.preventDefault();
442442
e.stopPropagation();
443443
}

test/select.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,20 @@ describe('ui-select tests', function() {
15241524

15251525
});
15261526

1527+
it('should stop the propagation when pressing ESC key from dropdown', function() {
1528+
1529+
var el = createUiSelectMultiple();
1530+
var searchInput = el.find('.ui-select-search');
1531+
spyOn(jQuery.Event.prototype, 'preventDefault');
1532+
spyOn(jQuery.Event.prototype, 'stopPropagation');
1533+
1534+
triggerKeydown(searchInput, Key.Down)
1535+
triggerKeydown(searchInput, Key.Escape)
1536+
expect(jQuery.Event.prototype.preventDefault).toHaveBeenCalled();
1537+
expect(jQuery.Event.prototype.stopPropagation).toHaveBeenCalled();
1538+
1539+
});
1540+
15271541
it('should increase $select.activeIndex when pressing DOWN key from dropdown', function() {
15281542

15291543
var el = createUiSelectMultiple();

0 commit comments

Comments
 (0)