@@ -37,6 +37,8 @@ export function PullRequestReviewerPicker({
3737 // Past the first page the host is asked, since what was loaded cannot answer for the rest.
3838 const searchQuery = useDebouncedValue ( query . trim ( ) , 250 ) ;
3939 const searchesHost = candidatesQuery . data ?. truncated === true && searchQuery . length > 0 ;
40+ // Only once the debounce has caught up, or rows matching the previous text would linger.
41+ const searched = searchesHost && searchQuery === query . trim ( ) ;
4042 const searchResult = useEnvironmentQuery (
4143 open && searchesHost
4244 ? pullRequestEnvironment . reviewerSearch ( {
@@ -51,7 +53,7 @@ export function PullRequestReviewerPicker({
5153
5254 const candidates = mergeReviewerCandidates (
5355 candidatesQuery . data ?. candidates ?? [ ] ,
54- searchesHost ? ( searchResult . data ?. candidates ?? [ ] ) : [ ] ,
56+ searched ? ( searchResult . data ?. candidates ?? [ ] ) : [ ] ,
5557 query ,
5658 ) ;
5759
@@ -113,16 +115,23 @@ export function PullRequestReviewerPicker({
113115 error = {
114116 candidatesQuery . data === null
115117 ? candidatesQuery . error
116- : searchesHost && candidates . length === 0
118+ : searched && candidates . length === 0
117119 ? searchResult . error
118120 : null
119121 }
120122 candidates = { candidates }
121123 emptyLabel = "Nobody else has access to this repository."
122124 noMatchLabel = "Nobody with access matches that."
123125 errorLabel = "The people with access could not be read."
124- truncated = { candidatesQuery . data ?. truncated === true && query . trim ( ) . length === 0 }
125- truncatedLabel = "This repository has more people with access than are listed here. Search to find them."
126+ truncated = {
127+ candidatesQuery . data ?. truncated === true &&
128+ ( query . trim ( ) . length === 0 || ( searched && searchResult . error !== null ) )
129+ }
130+ truncatedLabel = {
131+ searched && searchResult . error !== null
132+ ? `Only the people already listed are matched: the host search failed. ${ searchResult . error } `
133+ : "This repository has more people with access than are listed here. Search to find them."
134+ }
126135 candidateKey = { ( candidate ) => `${ candidate . kind } :${ candidate . id } ` }
127136 disabled = { pending !== null }
128137 onSelect = { ( candidate ) => void toggle ( candidate ) }
0 commit comments