Commit 3f399fe1 authored by Alfredo Sumaran's avatar Alfredo Sumaran

No need to pass event as a parameter

We should stop passing events as a parameter since we cannot call the method programatically without faking or creating an event even when that event is not entirely required.
parent c2912b46
...@@ -607,7 +607,7 @@ ...@@ -607,7 +607,7 @@
return this.dropdown.before($input); return this.dropdown.before($input);
}; };
GitLabDropdown.prototype.selectRowAtIndex = function(e, index) { GitLabDropdown.prototype.selectRowAtIndex = function(index) {
var $el, selector; var $el, selector;
selector = ".dropdown-content li:not(.divider,.dropdown-header,.separator):eq(" + index + ") a"; selector = ".dropdown-content li:not(.divider,.dropdown-header,.separator):eq(" + index + ") a";
if (this.dropdown.find(".dropdown-toggle-page").length) { if (this.dropdown.find(".dropdown-toggle-page").length) {
...@@ -615,8 +615,6 @@ ...@@ -615,8 +615,6 @@
} }
$el = $(selector, this.dropdown); $el = $(selector, this.dropdown);
if ($el.length) { if ($el.length) {
e.preventDefault();
e.stopImmediatePropagation();
return $el.first().trigger('click'); return $el.first().trigger('click');
} }
}; };
...@@ -653,7 +651,7 @@ ...@@ -653,7 +651,7 @@
return false; return false;
} }
if (currentKeyCode === 13 && currentIndex !== -1) { if (currentKeyCode === 13 && currentIndex !== -1) {
return _this.selectRowAtIndex(e, $('.is-focused', _this.dropdown).closest('li').index() - 1); return _this.selectRowAtIndex($('.is-focused', _this.dropdown).closest('li').index() - 1);
} }
}; };
})(this)); })(this));
......
...@@ -16,7 +16,7 @@ class ProtectedBranchCreate { ...@@ -16,7 +16,7 @@ class ProtectedBranchCreate {
}); });
// Select default // Select default
$allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(document.createEvent('Event'), 0); $allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0);
// Allowed to Push dropdowns // Allowed to Push dropdowns
new ProtectedBranchAccessDropdown({ new ProtectedBranchAccessDropdown({
...@@ -26,7 +26,7 @@ class ProtectedBranchCreate { ...@@ -26,7 +26,7 @@ class ProtectedBranchCreate {
}); });
// Select default // Select default
$allowedToPushDropdown.data('glDropdown').selectRowAtIndex(document.createEvent('Event'), 0); $allowedToPushDropdown.data('glDropdown').selectRowAtIndex(0);
new ProtectedBranchDropdowns({ new ProtectedBranchDropdowns({
$dropdowns: this.$wrap.find('.js-protected-branch-select'), $dropdowns: this.$wrap.find('.js-protected-branch-select'),
......
...@@ -44,9 +44,9 @@ class ProtectedBranchDropdown { ...@@ -44,9 +44,9 @@ class ProtectedBranchDropdown {
this.$protectedBranch.on('click', this.onClickCreateWildcard.bind(this)); this.$protectedBranch.on('click', this.onClickCreateWildcard.bind(this));
} }
onClickCreateWildcard(e) { onClickCreateWildcard() {
this.$dropdown.data('glDropdown').remote.execute(); this.$dropdown.data('glDropdown').remote.execute();
this.$dropdown.data('glDropdown').selectRowAtIndex(e, 0); this.$dropdown.data('glDropdown').selectRowAtIndex(0);
} }
getProtectedBranches(term, callback) { getProtectedBranches(term, callback) {
......
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