Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 28, 2025

Summary

Fixes #10645

When adding users to a project, the search bar incorrectly shows "No results found" when only 1 character is typed. The backend requires a minimum of 2 characters to return results.

Occurred changes and/or fixed issues

  • SelectPrincipal.vue: Added minimum character check before calling search API
  • When search string < 2 chars, displays "Type at least 2 characters to search" instead of "No results found"
  • Added translation key cluster.memberRoles.addClusterMember.minCharacters

Technical notes summary

  • Added hasSearchTooShort flag to track when search input is below threshold
  • minSearchLength constant (2) matches backend requirement
  • API call is skipped entirely when input too short, avoiding unnecessary requests

Areas or cases that should be tested

  • Project Members → Add → type single character → should show "Type at least 2 characters to search"
  • Type 2+ characters → should show search results or "No results found" if none match
  • Clear search → should reset to default state
  • Tested in Chrome; reviewer should test Firefox/Safari

Areas which could experience regressions

  • SelectPrincipal component used in cluster member assignment
  • Any other principal/user search dialogs using this component

Screenshot/Video

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes
  • The PR has been reviewed in terms of Accessibility
  • The PR has considered, and if applicable tested with, the three Global Roles Admin, Standard User and User Base
Original prompt

This section details on the original issue you should resolve

<issue_title>Search bar initially shows "No results found"</issue_title>
<issue_description><!--------- For bugs and general issues --------->
Setup

  • Rancher version: 2.7-head

Describe the bug
When adding users to a project, the search bar doesn't show the matching results until the 2nd character is typed.

To Reproduce

  1. Under Users & Authentication, create a new user (the kind of permissions are not relevant for this issue)
  2. Create a project in a cluster
  3. In the Members sessions, click Add
  4. Type the name of an existing user
  5. Observe the behavior of the search bar

Result
When adding users to a project, the search bar doesn't show the matching results until the 2nd character is typed. Also, the search engine shows the wrong message of "No results found"

Screen.Recording.2024-03-18.at.5.55.47.PM.mov

Expected Result
The search bar must show all matching results from the first character typed, and show the "No results found" message only when there are no matching results at all

</issue_description>

Comments on the Issue (you are @copilot in this section)

@nwmac I think the backend requires a minimum of 2 characters to return results, so we should handle that in the UI.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix search bar showing 'No results found' too early Fix search bar initially shows "No results found" Nov 28, 2025
Copilot AI requested a review from nwmac November 28, 2025 23:15
@nwmac nwmac requested a review from aalves08 November 29, 2025 12:14
@nwmac nwmac added this to the v2.14.0 milestone Nov 29, 2025
@nwmac nwmac marked this pull request as ready for review November 29, 2025 12:15
Copy link
Member

@aalves08 aalves08 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nwmac nwmac merged commit 1472be4 into master Dec 4, 2025
69 of 85 checks passed
@nwmac nwmac deleted the copilot/fix-search-bar-results branch December 4, 2025 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search bar initially shows "No results found"

3 participants