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);
}}
onClear={() => {
if (searchTerm) {
if (searchTerm || searchConversation) {
clearSearchQuery();
inputRef.current?.focus();
} else if (searchConversation) {
endConversationSearch();
inputRef.current?.focus();
} else {

View File

@@ -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,
};
}