From c0ebafe2bc3da9bfda6d6b83b0ef49cf578bcde6 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 9 Dec 2022 10:03:32 -0800 Subject: [PATCH] Search Box: Handle focus properly --- ts/components/CompositionArea.tsx | 2 +- ts/state/ducks/search.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ts/components/CompositionArea.tsx b/ts/components/CompositionArea.tsx index 47a326f5b..140498399 100644 --- a/ts/components/CompositionArea.tsx +++ b/ts/components/CompositionArea.tsx @@ -317,7 +317,7 @@ export function CompositionArea({ if (inputApiRef.current) { inputApiRef.current.focus(); } - }); + }, []); // Focus input whenever explicitly requested useEffect(() => { if (focusCounter !== previousFocusCounter && inputApiRef.current) { diff --git a/ts/state/ducks/search.ts b/ts/state/ducks/search.ts index a29a97b51..c0939dee2 100644 --- a/ts/state/ducks/search.ts +++ b/ts/state/ducks/search.ts @@ -339,7 +339,10 @@ export function reducer( } if (action.type === 'SEARCH_CLEAR') { - return getEmptyState(); + return { + ...getEmptyState(), + startSearchCounter: state.startSearchCounter, + }; } if (action.type === 'SEARCH_UPDATE') {