diff --git a/webapp/channels/src/components/suggestion/switch_channel_provider.test.tsx b/webapp/channels/src/components/suggestion/switch_channel_provider.test.tsx index aaaa2896206..1f2e5bd8fb5 100644 --- a/webapp/channels/src/components/suggestion/switch_channel_provider.test.tsx +++ b/webapp/channels/src/components/suggestion/switch_channel_provider.test.tsx @@ -587,7 +587,9 @@ describe('components/SwitchChannelProvider', () => { ]; expect(resultsCallback).toHaveBeenCalledWith(expect.objectContaining({ - terms: expectedOrder, + groups: [expect.objectContaining({ + terms: expectedOrder, + })], })); }); @@ -670,7 +672,9 @@ describe('components/SwitchChannelProvider', () => { ]; expect(resultsCallback).toHaveBeenCalledWith(expect.objectContaining({ - terms: expectedOrder, + groups: [expect.objectContaining({ + terms: expectedOrder, + })], })); }); @@ -757,7 +761,9 @@ describe('components/SwitchChannelProvider', () => { 'channel_other_user1', ]; expect(resultsCallback).toHaveBeenCalledWith(expect.objectContaining({ - terms: expectedOrder, + groups: [expect.objectContaining({ + terms: expectedOrder, + })], })); }); @@ -992,7 +998,9 @@ describe('components/SwitchChannelProvider', () => { ]; expect(resultsCallback).toHaveBeenCalledWith(expect.objectContaining({ - terms: expectedOrder, + groups: [expect.objectContaining({ + terms: expectedOrder, + })], })); }); diff --git a/webapp/channels/src/components/suggestion/switch_channel_provider.tsx b/webapp/channels/src/components/suggestion/switch_channel_provider.tsx index de2ae266ddb..d217866f6e6 100644 --- a/webapp/channels/src/components/suggestion/switch_channel_provider.tsx +++ b/webapp/channels/src/components/suggestion/switch_channel_provider.tsx @@ -574,7 +574,7 @@ export default class SwitchChannelProvider extends Provider { private initialFilteredList(channelPrefix: string, {items, terms}: {items: WrappedChannel[]; terms: string[]}): ProviderResults { let groups; - if (items) { + if (items && items.length > 0) { groups = [{ key: 'channels', label: defineMessage({id: 'suggestion.channels', defaultMessage: 'Channels'}), @@ -585,7 +585,7 @@ export default class SwitchChannelProvider extends Provider { } else { groups = [{ key: 'moreChannels', - label: defineMessage({id: 'suggestion.mention.morechannels', defaultMessage: 'Other Channels'}), + label: defineMessage({id: 'suggestion.channels', defaultMessage: 'Channels'}), items: [{type: '', loading: true}], terms: [''], component: ConnectedSwitchChannelSuggestion, @@ -654,9 +654,13 @@ export default class SwitchChannelProvider extends Provider { resultsCallback({ matchedPretext: channelPrefix, - items: combinedItems, - terms: combinedTerms, - component: ConnectedSwitchChannelSuggestion, + groups: [{ + key: 'channels', + label: defineMessage({id: 'suggestion.channels', defaultMessage: 'Channels'}), + items: combinedItems, + terms: combinedTerms, + component: ConnectedSwitchChannelSuggestion, + }], }); }