diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb index 9cf25915e92..88a0690938a 100644 --- a/app/controllers/concerns/issuable_collections.rb +++ b/app/controllers/concerns/issuable_collections.rb @@ -104,6 +104,12 @@ module IssuableCollections # Used by view to highlight active option @sort = options[:sort] + # When a user looks for an exact iid, we do not filter by search but only by iid + if params[:search] =~ /^#(?\d+)\z/ + options[:iids] = Regexp.last_match[:iid] + params[:search] = nil + end + if @project options[:project_id] = @project.id options[:attempt_project_search_optimizations] = true diff --git a/changelogs/unreleased/-30974-issue-search-by-number.yml b/changelogs/unreleased/-30974-issue-search-by-number.yml new file mode 100644 index 00000000000..1e6642ec102 --- /dev/null +++ b/changelogs/unreleased/-30974-issue-search-by-number.yml @@ -0,0 +1,5 @@ +--- +title: "Search issuables by iids" +merge_request: !28302 +author: Riccardo Padovani +type: fixed diff --git a/spec/controllers/concerns/issuable_collections_spec.rb b/spec/controllers/concerns/issuable_collections_spec.rb index fb2cd5ca955..f210537aad5 100644 --- a/spec/controllers/concerns/issuable_collections_spec.rb +++ b/spec/controllers/concerns/issuable_collections_spec.rb @@ -180,5 +180,16 @@ describe IssuableCollections do is_expected.not_to include('invalid_param', 'invalid_array') end end + + context 'search using an issue iid' do + let(:params) { { search: "#5" } } + + it 'mutates the search into a filter by iid' do + is_expected.to include({ + 'iids' => '5', + 'search' => nil + }) + end + end end end