diff --git a/ts/components/LeftPaneSearchInput.tsx b/ts/components/LeftPaneSearchInput.tsx index 8891cd1198..9a1c88fd0b 100644 --- a/ts/components/LeftPaneSearchInput.tsx +++ b/ts/components/LeftPaneSearchInput.tsx @@ -147,10 +147,8 @@ export function LeftPaneSearchInput({ changeValue(event.currentTarget.value); }} onClear={() => { - if (searchTerm) { + if (searchTerm || searchConversation) { clearSearchQuery(); - inputRef.current?.focus(); - } else if (searchConversation) { endConversationSearch(); inputRef.current?.focus(); } else { diff --git a/ts/state/ducks/search.ts b/ts/state/ducks/search.ts index ae76065a32..1c73928512 100644 --- a/ts/state/ducks/search.ts +++ b/ts/state/ducks/search.ts @@ -227,10 +227,22 @@ function endSearch(): EndSearchActionType { payload: null, }; } -function endConversationSearch(): EndConversationSearchActionType { - return { - type: 'END_CONVERSATION_SEARCH', - payload: null, +function endConversationSearch(): ThunkAction< + void, + RootStateType, + unknown, + EndConversationSearchActionType +> { + return async (dispatch, getState) => { + dispatch({ + type: 'END_CONVERSATION_SEARCH', + payload: null, + }); + + doSearch({ + dispatch, + state: getState(), + }); }; } function searchInConversation( @@ -791,8 +803,9 @@ export function reducer( if (action.type === 'END_CONVERSATION_SEARCH') { return { - ...getEmptyState(), + ...state, startSearchCounter: state.startSearchCounter + 1, + searchConversationId: undefined, globalSearch: true, }; }