Fix search dropdown not closing on blur if empty

This commit is contained in:
Luke Bennett 2019-05-24 20:20:05 +01:00
parent 12aff0b73c
commit 9181e4b135
No known key found for this signature in database
GPG key ID: 402ED51FB5D306C2
4 changed files with 21 additions and 2 deletions

View file

@ -405,7 +405,7 @@ export class SearchAutocomplete {
this.wrap.removeClass('search-active');
// If input is blank then restore state
if (this.searchInput.val() === '') {
return this.restoreOriginalState();
this.restoreOriginalState();
}
this.dropdownMenu.removeClass('show');
}

View file

@ -16,7 +16,7 @@
mr_path: merge_requests_dashboard_path },
aria: { label: _('Search or jump to…') }
%button.hidden.js-dropdown-search-toggle{ type: 'button', data: { toggle: 'dropdown' } }
.dropdown-menu.dropdown-select
.dropdown-menu.dropdown-select.js-dashboard-search-options
= dropdown_content do
%ul
%li.dropdown-menu-empty-item

View file

@ -0,0 +1,5 @@
---
title: Fix search dropdown not closing on blur if empty
merge_request: 28730
author:
type: fixed

View file

@ -25,4 +25,18 @@ describe 'Global search' do
expect(page).to have_selector('.gl-pagination .next')
end
end
it 'closes the dropdown on blur', :js do
visit dashboard_projects_path
fill_in 'search', with: "a"
dropdown = find('.js-dashboard-search-options')
expect(dropdown[:class]).to include 'show'
find('#search').send_keys(:backspace)
find('body').click
expect(dropdown[:class]).not_to include 'show'
end
end