From 3f399fe1817264246f978f542083962319ed0a82 Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Thu, 4 Aug 2016 01:44:04 -0500 Subject: [PATCH] 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. --- app/assets/javascripts/gl_dropdown.js | 6 ++---- app/assets/javascripts/protected_branch_create.js.es6 | 4 ++-- app/assets/javascripts/protected_branch_select.js.es6 | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/gl_dropdown.js b/app/assets/javascripts/gl_dropdown.js index cc7e422fd89..d3394fae3f9 100644 --- a/app/assets/javascripts/gl_dropdown.js +++ b/app/assets/javascripts/gl_dropdown.js @@ -607,7 +607,7 @@ return this.dropdown.before($input); }; - GitLabDropdown.prototype.selectRowAtIndex = function(e, index) { + GitLabDropdown.prototype.selectRowAtIndex = function(index) { var $el, selector; selector = ".dropdown-content li:not(.divider,.dropdown-header,.separator):eq(" + index + ") a"; if (this.dropdown.find(".dropdown-toggle-page").length) { @@ -615,8 +615,6 @@ } $el = $(selector, this.dropdown); if ($el.length) { - e.preventDefault(); - e.stopImmediatePropagation(); return $el.first().trigger('click'); } }; @@ -653,7 +651,7 @@ return false; } 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)); diff --git a/app/assets/javascripts/protected_branch_create.js.es6 b/app/assets/javascripts/protected_branch_create.js.es6 index 44e60e90998..a3115c8d0b5 100644 --- a/app/assets/javascripts/protected_branch_create.js.es6 +++ b/app/assets/javascripts/protected_branch_create.js.es6 @@ -16,7 +16,7 @@ class ProtectedBranchCreate { }); // Select default - $allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(document.createEvent('Event'), 0); + $allowedToMergeDropdown.data('glDropdown').selectRowAtIndex(0); // Allowed to Push dropdowns new ProtectedBranchAccessDropdown({ @@ -26,7 +26,7 @@ class ProtectedBranchCreate { }); // Select default - $allowedToPushDropdown.data('glDropdown').selectRowAtIndex(document.createEvent('Event'), 0); + $allowedToPushDropdown.data('glDropdown').selectRowAtIndex(0); new ProtectedBranchDropdowns({ $dropdowns: this.$wrap.find('.js-protected-branch-select'), diff --git a/app/assets/javascripts/protected_branch_select.js.es6 b/app/assets/javascripts/protected_branch_select.js.es6 index 6ca90453d49..e4881eea222 100644 --- a/app/assets/javascripts/protected_branch_select.js.es6 +++ b/app/assets/javascripts/protected_branch_select.js.es6 @@ -44,9 +44,9 @@ class ProtectedBranchDropdown { this.$protectedBranch.on('click', this.onClickCreateWildcard.bind(this)); } - onClickCreateWildcard(e) { + onClickCreateWildcard() { this.$dropdown.data('glDropdown').remote.execute(); - this.$dropdown.data('glDropdown').selectRowAtIndex(e, 0); + this.$dropdown.data('glDropdown').selectRowAtIndex(0); } getProtectedBranches(term, callback) {