Skip to content

Commit 9142f0d

Browse files
committed
Autofocus
1 parent 181c72b commit 9142f0d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

web/components/select-users.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ export function SelectUsers(props: {
3838
const requestId = useRef(0)
3939
const queryReady = query.length > 1
4040

41+
const inputRef = useRef<HTMLInputElement>(null)
42+
43+
useEffect(() => {
44+
// Wait for the modal (and transition) to finish
45+
const timeout = setTimeout(() => {
46+
inputRef.current?.focus()
47+
}, 100)
48+
return () => clearTimeout(timeout)
49+
}, [])
50+
4151
useEffect(() => {
4252
const id = ++requestId.current
4353
if (queryReady) {
@@ -66,6 +76,7 @@ export function SelectUsers(props: {
6676
<>
6777
<Col className="relative mt-1 w-full rounded-md">
6878
<Input
79+
ref={inputRef}
6980
type="text"
7081
name="user name"
7182
id="user name"

0 commit comments

Comments
 (0)