diff --git a/app/components/autocomplete/at_mention/at_mention.js b/app/components/autocomplete/at_mention/at_mention.js index d37f26db3..85f606880 100644 --- a/app/components/autocomplete/at_mention/at_mention.js +++ b/app/components/autocomplete/at_mention/at_mention.js @@ -64,7 +64,8 @@ export default class AtMention extends PureComponent { if (matchTerm !== this.props.matchTerm) { // if the term changed and we haven't made the request do that first const {currentTeamId, currentChannelId} = this.props; - this.props.actions.autocompleteUsers(matchTerm, currentTeamId, isSearch ? currentChannelId : ''); + const channelId = isSearch ? '' : currentChannelId; + this.props.actions.autocompleteUsers(matchTerm, currentTeamId, channelId); return; } diff --git a/app/selectors/autocomplete.js b/app/selectors/autocomplete.js index 4fd5b75bc..fc78a44f0 100644 --- a/app/selectors/autocomplete.js +++ b/app/selectors/autocomplete.js @@ -60,6 +60,10 @@ export const filterMembersInChannel = createSelector( getCurrentUserId, (state, matchTerm) => matchTerm, (profilesInChannel, currentUserId, matchTerm) => { + if (matchTerm === null) { + return null; + } + let profiles; if (matchTerm) { profiles = profilesInChannel.filter((p) => { @@ -81,6 +85,10 @@ export const filterMembersNotInChannel = createSelector( getCurrentUserId, (state, matchTerm) => matchTerm, (profilesNotInChannel, currentUserId, matchTerm) => { + if (matchTerm === null) { + return null; + } + let profiles; if (matchTerm) { profiles = profilesNotInChannel.filter((p) => { @@ -101,6 +109,10 @@ export const filterMembersInCurrentTeam = createSelector( getCurrentUser, (state, matchTerm) => matchTerm, (profilesInTeam, currentUser, matchTerm) => { + if (matchTerm === null) { + return null; + } + // FIXME: We need to include the currentUser here as is not in profilesInTeam on the redux store let profiles; if (matchTerm) { @@ -120,6 +132,10 @@ export const filterMyChannels = createSelector( getMyChannels, (state, opts) => opts, (myChannels, matchTerm) => { + if (matchTerm === null) { + return null; + } + let channels; if (matchTerm) { channels = myChannels.filter((c) => { @@ -140,6 +156,10 @@ export const filterOtherChannels = createSelector( getOtherChannels, (state, matchTerm) => matchTerm, (otherChannels, matchTerm) => { + if (matchTerm === null) { + return null; + } + let channels; if (matchTerm) { channels = otherChannels.filter((c) => { @@ -159,6 +179,10 @@ export const filterPublicChannels = createSelector( getCurrentLocale, (state, matchTerm) => matchTerm, (myChannels, otherChannels, locale, matchTerm) => { + if (matchTerm === null) { + return null; + } + let channels; if (matchTerm) { channels = myChannels.filter((c) => { @@ -181,6 +205,10 @@ export const filterPrivateChannels = createSelector( getMyChannels, (state, matchTerm) => matchTerm, (myChannels, matchTerm) => { + if (matchTerm === null) { + return null; + } + let channels; if (matchTerm) { channels = myChannels.filter((c) => {