diff --git a/web/chat/chat-thread-composer.react.js b/web/chat/chat-thread-composer.react.js --- a/web/chat/chat-thread-composer.react.js +++ b/web/chat/chat-thread-composer.react.js @@ -5,6 +5,7 @@ import { userSearchIndexForPotentialMembers } from 'lib/selectors/user-selectors'; import { getPotentialMemberItems } from 'lib/shared/search-utils'; +import { threadIsPending } from 'lib/shared/thread-utils'; import type { AccountUserInfo, UserListItem } from 'lib/types/user-types'; import Label from '../components/label.react'; @@ -105,15 +106,19 @@ usernameInputText, ]); - const hideSearch = React.useCallback(() => { - dispatch({ - type: updateNavInfoActionType, - payload: { - chatMode: 'view', - activeChatThreadID: threadID, - }, - }); - }, [dispatch, threadID]); + const hideSearch = React.useCallback( + (shouldChangeID = true) => { + dispatch({ + type: updateNavInfoActionType, + payload: { + chatMode: 'view', + activeChatThreadID: + shouldChangeID || !threadIsPending(threadID) ? threadID : '', + }, + }); + }, + [dispatch, threadID], + ); const tagsList = React.useMemo(() => { if (!userInfoInputArray?.length) { @@ -155,7 +160,12 @@ placeholder="Select users for chat" /> -
+
{ + hideSearch(false); + }} + >