Commit a4933772 authored by Phil Hughes's avatar Phil Hughes

Merge branch...

Merge branch '31987-automatically-close-assignee-select-dropdown-after-selection-when-multiple-assignees-is-disabled' into 'master'

Automatically close user dropdown for CE

Closes #31987

See merge request !11189
parents 3bbf9575 fbe1e00e
......@@ -421,6 +421,15 @@ function UsersSelect(currentUser, els) {
selected = $dropdown.closest('.selectbox').find("input[name='" + ($dropdown.data('field-name')) + "']").val();
return assignTo(selected);
}
// Automatically close dropdown after assignee is selected
// since CE has no multiple assignees
// EE does not have a max-select
if ($dropdown.data('max-select') &&
getSelected().length === $dropdown.data('max-select')) {
// Close the dropdown
$dropdown.dropdown('toggle');
}
},
id: function (user) {
return user.id;
......
......@@ -115,7 +115,6 @@ describe 'Issue Boards', feature: true, js: true do
click_link 'Unassigned'
end
find('.dropdown-menu-toggle').click
wait_for_vue_resource
expect(page).to have_content('No assignee')
......
......@@ -24,10 +24,10 @@ describe 'New/edit issue', :feature, :js do
visit new_namespace_project_issue_path(project.namespace, project)
end
describe 'multiple assignees' do
describe 'single assignee' do
before do
click_button 'Unassigned'
wait_for_ajax
end
......@@ -36,14 +36,12 @@ describe 'New/edit issue', :feature, :js do
click_link user2.name
end
click_button user2.name
page.within '.dropdown-menu-user' do
click_link 'Unassigned'
end
page.within '.js-assignee-search' do
expect(page).to have_content 'Unassigned'
end
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match('0')
end
......@@ -54,11 +52,13 @@ describe 'New/edit issue', :feature, :js do
expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
page.within '.dropdown-menu-user' do
click_button user.name
page.within('.dropdown-menu-user') do
click_link user.name
end
expect(find('a', text: 'Assign to me')).to be_visible
expect(page.find('.dropdown-menu-user', visible: false)).not_to be_visible
end
end
......@@ -154,25 +154,21 @@ describe 'New/edit issue', :feature, :js do
it 'correctly updates the selected user when changing assignee' do
click_button 'Unassigned'
wait_for_ajax
page.within '.dropdown-menu-user' do
click_link user.name
end
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match(user.id.to_s)
expect(find('.dropdown-menu-user a.is-active').first(:xpath, '..')['data-user-id']).to eq(user.id.to_s)
# check the ::before pseudo element to ensure checkmark icon is present
expect(before_for_selector('.dropdown-menu-selectable a.is-active')).not_to eq('')
expect(before_for_selector('.dropdown-menu-selectable a:not(.is-active)')).to eq('')
expect(find('.js-assignee-search')).to have_content(user.name)
click_button user.name
page.within '.dropdown-menu-user' do
click_link user2.name
end
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match(user2.id.to_s)
expect(find('.dropdown-menu-user a.is-active').first(:xpath, '..')['data-user-id']).to eq(user2.id.to_s)
expect(find('.js-assignee-search')).to have_content(user2.name)
end
end
......
......@@ -465,8 +465,6 @@ describe 'Issues', feature: true do
click_link 'Edit'
click_link @user.name
find('.dropdown-menu-toggle').click
page.within '.value .author' do
expect(page).to have_content @user.name
end
......@@ -474,8 +472,6 @@ describe 'Issues', feature: true do
click_link 'Edit'
click_link @user.name
find('.dropdown-menu-toggle').click
page.within '.value .assign-yourself' do
expect(page).to have_content "No assignee"
end
......
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