[Spike] Improve accuracy of group selector in Branch Rules
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=498245) </details> <!--IssueSummary end--> ## Context We've [recently changed `filterKey` for group selector from `name` to `id`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/166818/diffs) to make sure users can select multiple (different) groups with the same name. More context in [Unable to select multiple groups with same name in MR approval rules drawer](https://gitlab.com/gitlab-org/gitlab/-/issues/481446). However, we've seen a report of returned groups not matching the search string. See the example of searching for `gitlab-org` from all groups in Duo UI project: ![Screenshot_2024-10-08_at_13.29.23](/uploads/65fd7a839ec0c40b2e60320791efcf52/Screenshot_2024-10-08_at_13.29.23.png) Here's a little investigation I did inside GitLab repository. I started typing the same string `gitlab-org`. I was given 3 results: returned group for still empty string, returned group for an incomplete string and returned groups for a complete string. The dropdown with results updated dynamically, and asynchronously from what I was typing (the last changed happened a moment after I stopped typing). Notice that different results where displayed in the dropdown, when the input already contained the complete string. | search string | respond | screenshot | | ------------- | ------ | ------ | | ` ` | [empty-string-request.json](/uploads/e4c5f151122a7d7196ceb419655f0266/empty-string-request.json) ![Screenshot_2024-10-08_at_18.01.55](/uploads/606a32f868fc401e5d6347a04cb864b1/Screenshot_2024-10-08_at_18.01.55.png) | ![Screenshot_2024-10-08_at_18.00.45](/uploads/ad3a97de400bfe4f1e7e594c30adbc62/Screenshot_2024-10-08_at_18.00.45.png) | | `gitlab-` | [gitlab-dash-request.json](/uploads/d07be16cfb03d7447125a7e91928b0f9/gitlab-dash-request.json) ![Screenshot_2024-10-08_at_18.02.02](/uploads/6fb4c7c3b20dbb8dafd1d1c748f3ba9f/Screenshot_2024-10-08_at_18.02.02.png) | ![Screenshot_2024-10-08_at_18.01.27](/uploads/77ab025a2b6b75c612726b3e811393e9/Screenshot_2024-10-08_at_18.01.27.png) | | `gitlab-org` | [gitlab-dash-org-request.json](/uploads/7a6c5faadc0cc29088be08abb3b2681e/gitlab-dash-org-request.json) ![Screenshot_2024-10-08_at_18.02.09](/uploads/62b061e50f425f47eb81fd957cdbef53/Screenshot_2024-10-08_at_18.02.09.png) | ![Screenshot_2024-10-08_at_18.06.23](/uploads/f023620b16ee4dabe72ad0f05188f1db/Screenshot_2024-10-08_at_18.06.23.png) | ## Questions We want to rethink the way the search works, so that it is not confusing and returns helpful information. - When should we call the endpoint? Do we want to debounce? - How dynamic should it be? - Should we sort the results in some way?
issue