Skip to content

Commit 42f71df

Browse files
authored
fix(web): PR search keeps the caret where you type (pingdotgg#17675)
1 parent 500cb42 commit 42f71df

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,21 @@ export function PullRequestSearchInput({
104104
busy?: boolean;
105105
onChange: (value: string) => void;
106106
}) {
107+
const [draft, setDraft] = useState<string | null>(null);
107108
return (
108109
<InputGroup className="min-w-0 flex-1 **:[input]:h-9 sm:**:[input]:h-8">
109110
<InputGroupAddon>
110111
{busy ? <Spinner aria-hidden /> : <SearchIcon aria-hidden />}
111112
</InputGroupAddon>
112113
<InputGroupInput
113114
type="search"
114-
value={value}
115-
onChange={(event) => onChange(event.currentTarget.value)}
115+
value={draft ?? value}
116+
onFocus={() => setDraft(value)}
117+
onBlur={() => setDraft(null)}
118+
onChange={(event) => {
119+
setDraft(event.currentTarget.value);
120+
onChange(event.currentTarget.value);
121+
}}
116122
placeholder="Search pull requests, or label:bug"
117123
aria-label="Search pull requests"
118124
/>

0 commit comments

Comments
 (0)