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

Commit af01d52

Browse files
committed
Stop propagation when pressing ENTER key from dropdown
1 parent 948d383 commit af01d52

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/uiSelectController.js

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

440+
if (key === KEY.ENTER) {
441+
e.preventDefault();
442+
e.stopPropagation();
443+
}
444+
440445
});
441446

442447
// If tagging try to split by tokens and add items

test/select.spec.js

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

15111511
});
15121512

1513+
it('should stop the propagation when pressing ENTER key from dropdown', function() {
1514+
1515+
var el = createUiSelectMultiple();
1516+
var searchInput = el.find('.ui-select-search');
1517+
spyOn(jQuery.Event.prototype, 'preventDefault');
1518+
spyOn(jQuery.Event.prototype, 'stopPropagation');
1519+
1520+
triggerKeydown(searchInput, Key.Down)
1521+
triggerKeydown(searchInput, Key.Enter)
1522+
expect(jQuery.Event.prototype.preventDefault).toHaveBeenCalled();
1523+
expect(jQuery.Event.prototype.stopPropagation).toHaveBeenCalled();
1524+
1525+
});
1526+
15131527
it('should increase $select.activeIndex when pressing DOWN key from dropdown', function() {
15141528

15151529
var el = createUiSelectMultiple();

0 commit comments

Comments
 (0)