Skip to content
Snippets Groups Projects
Commit 88c74c74 authored by Phil Hughes's avatar Phil Hughes
Browse files

Fixed enter key in search input not working

Closes #20627
parent cd102716
No related branches found
No related tags found
No related merge requests found
Pipeline #
Loading
Loading
@@ -32,7 +32,7 @@
.on('keydown', function (e) {
var keyCode = e.which;
 
if (keyCode === 13) {
if (keyCode === 13 && !options.elIsInput) {
e.preventDefault()
}
})
Loading
Loading
@@ -47,7 +47,7 @@
} else if (this.input.val() === "" && $inputContainer.hasClass(HAS_VALUE_CLASS)) {
$inputContainer.removeClass(HAS_VALUE_CLASS);
}
if (keyCode === 13) {
if (keyCode === 13 && !options.elIsInput) {
return false;
}
if (this.options.remote) {
Loading
Loading
@@ -232,6 +232,7 @@
}
if (this.options.filterable) {
this.filter = new GitLabDropdownFilter(this.filterInput, {
elIsInput: $(this.el).is('input'),
filterInputBlur: this.filterInputBlur,
filterByText: this.options.filterByText,
onFilter: this.options.onFilter,
Loading
Loading
@@ -260,8 +261,12 @@
if (_this.dropdown.find('.dropdown-toggle-page').length) {
selector = ".dropdown-page-one " + selector;
}
$(selector, _this.dropdown).first().find('a').addClass('is-focused');
return currentIndex = 0;
if ($(_this.el).is('input')) {
currentIndex = -1;
} else {
$(selector, _this.dropdown).first().find('a').addClass('is-focused');
currentIndex = 0;
}
}
};
})(this)
Loading
Loading
@@ -609,13 +614,13 @@
 
GitLabDropdown.prototype.selectRowAtIndex = function(index) {
var $el, selector;
selector = ".dropdown-content li:not(.divider,.dropdown-header,.separator):eq(" + index + ") a";
selector = ".dropdown-content .is-focused";
if (this.dropdown.find(".dropdown-toggle-page").length) {
selector = ".dropdown-page-one " + selector;
}
$el = $(selector, this.dropdown);
if ($el.length) {
return $el.first().trigger('click');
$el.first()[0].click();
}
};
 
Loading
Loading
@@ -651,7 +656,7 @@
return false;
}
if (currentKeyCode === 13 && currentIndex !== -1) {
return _this.selectRowAtIndex($('.is-focused', _this.dropdown).closest('li').index() - 1);
_this.selectRowAtIndex($('.is-focused', _this.dropdown).closest('li').index());
}
};
})(this));
Loading
Loading
Loading
Loading
@@ -71,6 +71,16 @@ describe "Search", feature: true do
end
 
describe 'Right header search field', feature: true do
it 'allows enter key to search', js: true do
visit namespace_project_path(project.namespace, project)
fill_in 'search', with: 'gitlab'
find('#search').native.send_keys(:enter)
page.within '.title' do
expect(page).to have_content 'Search'
end
end
describe 'Search in project page' do
before do
visit namespace_project_path(project.namespace, project)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment