Skip to content

Commit

Permalink
Site search not focusing on open fixed (#1076)
Browse files Browse the repository at this point in the history
  • Loading branch information
babyo77 authored Oct 7, 2024
1 parent bc82b28 commit 0cadee6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions components/ui/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,15 @@ function SearchDialog({
setOpen(false);
}, [pathname, searchParams, setOpen]);

// added auto-focus when dialog opened
useEffect(() => {
if (open) {
setTimeout(() => {
inputRef.current?.focus();
}, 0);
}
}, [open]);

useEffect(() => {
if (open) {
return;
Expand Down

0 comments on commit 0cadee6

Please sign in to comment.