Commit 90b81bf9 authored by Simon Knox's avatar Simon Knox

Merge branch '240924-add-milestone-async-search-support' into 'master'

Make milestone dropdown search async

Closes #240924

See merge request gitlab-org/gitlab!40305
parents ac26955d 453aadde
...@@ -76,6 +76,10 @@ export default class MilestoneSelect { ...@@ -76,6 +76,10 @@ export default class MilestoneSelect {
let getMilestones = Api.projectMilestones; let getMilestones = Api.projectMilestones;
const reqParams = { state: 'active', include_parent_milestones: true }; const reqParams = { state: 'active', include_parent_milestones: true };
if (term) {
reqParams.search = term.trim();
}
if (!contextId) { if (!contextId) {
contextId = $dropdown.get(0).dataset.groupId; contextId = $dropdown.get(0).dataset.groupId;
delete reqParams.include_parent_milestones; delete reqParams.include_parent_milestones;
...@@ -162,6 +166,7 @@ export default class MilestoneSelect { ...@@ -162,6 +166,7 @@ export default class MilestoneSelect {
`; `;
}, },
filterable: true, filterable: true,
filterRemote: true,
search: { search: {
fields: ['title'], fields: ['title'],
}, },
......
...@@ -4,13 +4,17 @@ require "spec_helper" ...@@ -4,13 +4,17 @@ require "spec_helper"
RSpec.describe "Issues > User edits issue", :js do RSpec.describe "Issues > User edits issue", :js do
let_it_be(:project) { create(:project_empty_repo, :public) } let_it_be(:project) { create(:project_empty_repo, :public) }
let_it_be(:project_with_milestones) { create(:project_empty_repo, :public) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:issue) { create(:issue, project: project, author: user, assignees: [user]) } let_it_be(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
let_it_be(:issue_with_milestones) { create(:issue, project: project_with_milestones, author: user, assignees: [user]) }
let_it_be(:label) { create(:label, project: project) } let_it_be(:label) { create(:label, project: project) }
let_it_be(:milestone) { create(:milestone, project: project) } let_it_be(:milestone) { create(:milestone, project: project) }
let_it_be(:milestones) { create_list(:milestone, 25, project: project_with_milestones) }
before do before do
project.add_developer(user) project.add_developer(user)
project_with_milestones.add_developer(user)
sign_in(user) sign_in(user)
end end
...@@ -218,6 +222,23 @@ RSpec.describe "Issues > User edits issue", :js do ...@@ -218,6 +222,23 @@ RSpec.describe "Issues > User edits issue", :js do
end end
end end
end end
it 'allows user to search milestone' do
visit project_issue_path(project_with_milestones, issue_with_milestones)
page.within('.milestone') do
click_link 'Edit'
wait_for_requests
# We need to enclose search string in quotes for exact match as all the milestone titles
# within tests are prefixed with `My title`.
find('.dropdown-input-field', visible: true).send_keys "\"#{milestones[0].title}\""
wait_for_requests
page.within '.dropdown-content' do
expect(page).to have_content milestones[0].title
end
end
end
end end
context 'by unauthorized user' do context 'by unauthorized user' do
......
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