Setting the custom searchFunction to get only channels for Channel List
Hello
Setting the custom searchFunction to get only channels for Channel List is not showing up as expected.
This is my ChannelList component
<ChannelList
filters={filters}
sort={sort}
showChannelSearch
additionalChannelSearchProps={{
searchForChannels: true,
searchFunction: async (ChannelSearchFunctionParams, event) => {
ChannelSearchFunctionParams.setQuery(event.target.value);
const channels = await chatClient.queryChannels(filters, sort);
ChannelSearchFunctionParams.setResults(channels);
},
}}
List={ChannelListMessenger}
customActiveChannel={memberChannelId}
/>
and his is what I get after dispatching all channels
I have no idea why it shows up like this?
Hello! Thanks for writing in. Excellent use of writing your own search function for the input.
By default, a search result in the dropdown list for channels displays the channel name, which is optional. Do your channels have names? That could be the issue. I'd suggest creating your own SearchResultItem component that will handle the display of your channel results (maybe the id or members if no name?) and pass it in into your additionalChannelSearchProps. See the Channel Search guide in our documentation that outlines several customization options including how to use a custom result item component. I believe that should help so I'm going to close this issue, but if you find that's not the issue then please reach back out. Thanks!
@ambaldwin if I stick with the default channel search functionality that getStream provides out of the box, then it displays the channel names as expected (by using the showChannelSearch with no custom searchFunction), but the problem occurs when I use chatClient.queryChannels - the strange thing is that I've implemented the customDropdown component but no names are visible there as well.
@ambaldwin also you asked whether my channels contain names, As I checked the result that is returned from chatClient.queryChannels contains channel objects which does not contain channel names. And I have no idea why, can you explain to me?
The channels returned do not contain names in the data object? so, if you log channel.data, let me know what you see.
Also, in your custom implementation of a CustomDropdown component, are you using a custom SearchResultItem as well? If not, then it will use the default, and this is the component that will display names only if there is one.
Note that the searchFunction's second argument is the event, so a query might look like this:
const channelResponse = await chatClient.queryChannels(
{
name: { $autocomplete: event.target.value },
members: { $in: [userId] }
},
);
this is how the channel object looks like:

@ambaldwin thanks for your reply. I know that your code should work but it does not work for me. I am even doing this:
const channelResponse = await chatClient.queryChannels(
{
name: { $autocomplete: 'John' },
},
);
without passing members filter, but it still returns an empty result (I am pretty sure that the result set contains user/channel with a name John.) So maybe it is something that is related with permissions or chat configuration?
Hello, I apologize for the delay - Are you still having issues? Let's try to trouble-shoot - you say you see the channel names if you use the default search function instead of providing your own. Can you send a screenshot of the logs of these channel objects with the names and/or a screenshot of the dropdown menu where you're seeing the names displayed?