Skip to content

Commit 99a28ad

Browse files
fix(web): an author picked from the host's search stays shown
The author picker resolved its selection only among authors on loaded rows, so an author found through the host's search vanished from the menu once picked. It falls back to the host's answer, then to the login itself, as the label picker already did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 7da05d3 commit 99a28ad

3 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎apps/web/src/components/pullRequest/PullRequestListFilters.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
4949
import {
5050
pullRequestAuthorChoices,
51+
selectedPullRequestAuthor,
5152
pullRequestLabelChoices,
5253
pullRequestLabelColor,
5354
type PullRequestAuthorFacet,
@@ -305,7 +306,7 @@ function PullRequestAuthorChoices({
305306
const [query, setQuery] = useState("");
306307
const hosted = useHostedFilterOptions(scope, "authors", query);
307308
const login = value?.toLowerCase() ?? "";
308-
const selected = options.find((option) => option.actor.login.toLowerCase() === login);
309+
const selected = selectedPullRequestAuthor(options, hosted.authors, value);
309310
const visible = [
310311
...(selected ? [selected] : []),
311312
...pullRequestAuthorChoices(options, hosted.authors, query).filter(

‎apps/web/src/components/pullRequest/pullRequestList.logic.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
readPullRequestListSnapshot,
2626
writePullRequestListSnapshot,
2727
pullRequestAuthorChoices,
28+
selectedPullRequestAuthor,
2829
pullRequestLabelChoices,
2930
rankPullRequestMatches,
3031
rankPullRequestsBlockedOnAuthor,
@@ -839,6 +840,18 @@ describe("filter picker choices", () => {
839840
]);
840841
});
841842

843+
it("keeps showing an author picked from the host's search once the search clears", () => {
844+
const loaded = [{ actor: actor("julius"), count: 4, mergedCount: 3 }];
845+
const hosted = [actor("Juliana", "Juliana")];
846+
847+
expect(selectedPullRequestAuthor(loaded, hosted, "juliana")?.actor).toEqual(
848+
actor("Juliana", "Juliana"),
849+
);
850+
expect(selectedPullRequestAuthor(loaded, [], "juliana")?.actor.login).toBe("juliana");
851+
expect(selectedPullRequestAuthor(loaded, hosted, "JULIUS")?.count).toBe(4);
852+
expect(selectedPullRequestAuthor(loaded, hosted, undefined)).toBeUndefined();
853+
});
854+
842855
it("keeps a loaded label's count when only the host's search found it", () => {
843856
const loaded = [{ name: "size:XL", color: "d93f0b", count: 7 }];
844857

‎apps/web/src/components/pullRequest/pullRequestList.logic.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,30 @@ export function pullRequestAuthorChoices(
158158
return [...loaded, ...added];
159159
}
160160

161+
/**
162+
* The author a filter names, as a choice: an author picked from the host's answer is on no
163+
* loaded row, so it stays shown after the search that found it clears.
164+
*/
165+
export function selectedPullRequestAuthor(
166+
facets: ReadonlyArray<PullRequestAuthorFacet>,
167+
hosted: ReadonlyArray<PullRequestActor>,
168+
value: string | undefined,
169+
): PullRequestAuthorFacet | undefined {
170+
if (value === undefined) return undefined;
171+
const key = normalize(value);
172+
return (
173+
facets.find((facet) => normalize(facet.actor.login) === key) ?? {
174+
actor: hosted.find((actor) => normalize(actor.login) === key) ?? {
175+
login: value,
176+
name: null,
177+
avatarUrl: null,
178+
},
179+
count: 0,
180+
mergedCount: 0,
181+
}
182+
);
183+
}
184+
161185
export function pullRequestLabelChoices(
162186
facets: ReadonlyArray<PullRequestLabelFacet>,
163187
hosted: ReadonlyArray<PullRequestLabel>,

0 commit comments

Comments
 (0)