From c546e69739e68bb74fbc877eb62609928e5b8de6 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Mon, 15 Sep 2025 12:34:51 -0600 Subject: [PATCH] fix: zulip stream and topic selection in share dialog (#644) * fix: zulip stream and topic selection in share dialog Replace useListCollection with createListCollection to match the working room edit implementation. This ensures collections update when data loads, fixing the issue where streams and topics wouldn't appear until navigation. * fix: wrap createListCollection in useMemo to prevent recreation on every render Both streamCollection and topicCollection are now memoized to improve performance and prevent unnecessary re-renders of Combobox components --- www/app/(app)/transcripts/shareZulip.tsx | 43 +++++++++++------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/www/app/(app)/transcripts/shareZulip.tsx b/www/app/(app)/transcripts/shareZulip.tsx index 5cee16c1..bee14822 100644 --- a/www/app/(app)/transcripts/shareZulip.tsx +++ b/www/app/(app)/transcripts/shareZulip.tsx @@ -14,8 +14,7 @@ import { Checkbox, Combobox, Spinner, - useFilter, - useListCollection, + createListCollection, } from "@chakra-ui/react"; import { TbBrandZulip } from "react-icons/tb"; import { @@ -48,8 +47,6 @@ export default function ShareZulip(props: ShareZulipProps & BoxProps) { const { data: topics = [] } = useZulipTopics(selectedStreamId); const postToZulipMutation = useTranscriptPostToZulip(); - const { contains } = useFilter({ sensitivity: "base" }); - const streamItems = useMemo(() => { return streams.map((stream: Stream) => ({ label: stream.name, @@ -64,17 +61,21 @@ export default function ShareZulip(props: ShareZulipProps & BoxProps) { })); }, [topics]); - const { collection: streamItemsCollection, filter: streamItemsFilter } = - useListCollection({ - initialItems: streamItems, - filter: contains, - }); + const streamCollection = useMemo( + () => + createListCollection({ + items: streamItems, + }), + [streamItems], + ); - const { collection: topicItemsCollection, filter: topicItemsFilter } = - useListCollection({ - initialItems: topicItems, - filter: contains, - }); + const topicCollection = useMemo( + () => + createListCollection({ + items: topicItems, + }), + [topicItems], + ); // Update selected stream ID when stream changes useEffect(() => { @@ -156,15 +157,12 @@ export default function ShareZulip(props: ShareZulipProps & BoxProps) { # { setTopic(undefined); setStream(e.value[0]); }} - onInputValueChange={(e) => - streamItemsFilter(e.inputValue) - } openOnClick={true} positioning={{ strategy: "fixed", @@ -181,7 +179,7 @@ export default function ShareZulip(props: ShareZulipProps & BoxProps) { No streams found - {streamItemsCollection.items.map((item) => ( + {streamItems.map((item) => ( {item.label} @@ -197,12 +195,9 @@ export default function ShareZulip(props: ShareZulipProps & BoxProps) { # setTopic(e.value[0])} - onInputValueChange={(e) => - topicItemsFilter(e.inputValue) - } openOnClick selectionBehavior="replace" skipAnimationOnMount={true} @@ -222,7 +217,7 @@ export default function ShareZulip(props: ShareZulipProps & BoxProps) { No topics found - {topicItemsCollection.items.map((item) => ( + {topicItems.map((item) => ( {item.label}