Skip to content

Commit

Permalink
Re-focus search form on IP modal close πŸ‘€
Browse files Browse the repository at this point in the history
  • Loading branch information
wotschofsky committed Sep 19, 2024
1 parent a221079 commit 9d2c2b9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/_components/search-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ export const SearchForm: FC<SearchFormProps> = (props) => {
setSuggestionsVisible(true);
}, [isFirstRender, setSuggestionsVisible]);

const handleIpDetailsOpenChange = useCallback(
(open: boolean) => {
setIpDetailsOpen(open);
if (!open) {
inputRef.current?.focus();
}
},
[setIpDetailsOpen, inputRef]
);

return (
<>
<form className="flex gap-3" onSubmit={handleSubmit}>
Expand Down Expand Up @@ -357,7 +367,7 @@ export const SearchForm: FC<SearchFormProps> = (props) => {
<IpDetailsModal
ip={domain.trim()}
open={ipDetailsOpen}
onOpenChange={setIpDetailsOpen}
onOpenChange={handleIpDetailsOpenChange}
/>
</>
);
Expand Down

0 comments on commit 9d2c2b9

Please sign in to comment.