diff options
author | Phil Hughes <me@iamphill.com> | 2018-02-27 16:21:28 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-02-27 16:21:28 +0000 |
commit | 566dc70b5059c56fd46dd0461977960d5ee0fdf3 (patch) | |
tree | c83bb34a32aafb914cf8ea1d52614167ac58d3d8 | |
parent | 7d12f3a84e39c6be6f3798e37b39f0023ece71ec (diff) | |
parent | 13a7fde703ea820ce5649bb549aac4f8a3d8b560 (diff) | |
download | gitlab-ce-566dc70b5059c56fd46dd0461977960d5ee0fdf3.tar.gz |
Merge branch '24774-clear-the-Labels-dropdown-search-filter' into 'master'
Clear "Labels" dropdown search filter after selection
Closes #24774
See merge request gitlab-org/gitlab-ce!17393
-rw-r--r-- | app/assets/javascripts/labels_select.js | 6 | ||||
-rw-r--r-- | changelogs/unreleased/24774-clear-the-Labels-dropdown-search-filter.yml | 5 | ||||
-rw-r--r-- | spec/features/issues/form_spec.rb | 12 |
3 files changed, 23 insertions, 0 deletions
diff --git a/app/assets/javascripts/labels_select.js b/app/assets/javascripts/labels_select.js index 7151ac05a09..89a246f56cf 100644 --- a/app/assets/javascripts/labels_select.js +++ b/app/assets/javascripts/labels_select.js @@ -242,10 +242,16 @@ export default class LabelsSelect { filterable: true, selected: $dropdown.data('selected') || [], toggleLabel: function(selected, el) { + var $dropdownParent = $dropdown.parent(); + var $dropdownInputField = $dropdownParent.find('.dropdown-input-field'); var isSelected = el !== null ? el.hasClass('is-active') : false; var title = selected.title; var selectedLabels = this.selected; + if ($dropdownInputField.length && $dropdownInputField.val().length) { + $dropdownParent.find('.dropdown-input-clear').trigger('click'); + } + if (selected.id === 0) { this.selected = []; return 'No Label'; diff --git a/changelogs/unreleased/24774-clear-the-Labels-dropdown-search-filter.yml b/changelogs/unreleased/24774-clear-the-Labels-dropdown-search-filter.yml new file mode 100644 index 00000000000..b909bb2d021 --- /dev/null +++ b/changelogs/unreleased/24774-clear-the-Labels-dropdown-search-filter.yml @@ -0,0 +1,5 @@ +--- +title: Clear the Labels dropdown search filter after a selection is made +merge_request: 17393 +author: Andrew Torres +type: changed diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index c2c4b479a8a..ef6b8edd0ad 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -189,6 +189,18 @@ describe 'New/edit issue', :js do expect(find('.js-label-select')).to have_content('Labels') end + it 'clears label search input field when a label is selected' do + click_button 'Labels' + + page.within '.dropdown-menu-labels' do + search_field = find('input[type="search"]') + + search_field.set(label2.title) + click_link label2.title + expect(search_field.value).to eq '' + end + end + it 'correctly updates the selected user when changing assignee' do click_button 'Unassigned' |