diff --git a/src/app/features/forum/ForumNewPostModal.tsx b/src/app/features/forum/ForumNewPostModal.tsx index 1cd3155a..7a1f0df9 100644 --- a/src/app/features/forum/ForumNewPostModal.tsx +++ b/src/app/features/forum/ForumNewPostModal.tsx @@ -275,7 +275,6 @@ export function ForumNewPostModal({ onChange={(e) => setTitle(e.target.value)} maxLength={140} required - autoFocus placeholder="Title" aria-label="Title" autoComplete="off" diff --git a/src/app/hooks/useAsyncSearch.ts b/src/app/hooks/useAsyncSearch.ts index 8518a8bd..84b4d8f0 100644 --- a/src/app/hooks/useAsyncSearch.ts +++ b/src/app/hooks/useAsyncSearch.ts @@ -112,8 +112,6 @@ export const useAsyncSearch = ( const [result, setResult] = useState>(); const [searchCallback, terminateSearch] = useMemo(() => { - setResult(undefined); - const handleMatch: MatchHandler = (item, query) => { const itemStr = getItemStr(item, query); @@ -143,13 +141,15 @@ export const useAsyncSearch = ( setResult(undefined); }, [terminateSearch]); - useEffect( - () => () => { + useEffect(() => { + // clear stale results whenever the search source is recreated + setResult(undefined); + + return () => { // terminate any ongoing search request on unmount. terminateSearch(); - }, - [terminateSearch], - ); + }; + }, [terminateSearch]); return [result, searchHandler, resetHandler]; };