Improve left pane search bar behavior

This commit is contained in:
Fedor Indutny
2025-08-28 11:36:19 -07:00
committed by GitHub
parent bc33de9149
commit 1b4aecd2f0
2 changed files with 19 additions and 8 deletions

View File

@@ -147,10 +147,8 @@ export function LeftPaneSearchInput({
changeValue(event.currentTarget.value); changeValue(event.currentTarget.value);
}} }}
onClear={() => { onClear={() => {
if (searchTerm) { if (searchTerm || searchConversation) {
clearSearchQuery(); clearSearchQuery();
inputRef.current?.focus();
} else if (searchConversation) {
endConversationSearch(); endConversationSearch();
inputRef.current?.focus(); inputRef.current?.focus();
} else { } else {

View File

@@ -227,10 +227,22 @@ function endSearch(): EndSearchActionType {
payload: null, payload: null,
}; };
} }
function endConversationSearch(): EndConversationSearchActionType { function endConversationSearch(): ThunkAction<
return { void,
RootStateType,
unknown,
EndConversationSearchActionType
> {
return async (dispatch, getState) => {
dispatch({
type: 'END_CONVERSATION_SEARCH', type: 'END_CONVERSATION_SEARCH',
payload: null, payload: null,
});
doSearch({
dispatch,
state: getState(),
});
}; };
} }
function searchInConversation( function searchInConversation(
@@ -791,8 +803,9 @@ export function reducer(
if (action.type === 'END_CONVERSATION_SEARCH') { if (action.type === 'END_CONVERSATION_SEARCH') {
return { return {
...getEmptyState(), ...state,
startSearchCounter: state.startSearchCounter + 1, startSearchCounter: state.startSearchCounter + 1,
searchConversationId: undefined,
globalSearch: true, globalSearch: true,
}; };
} }