diff --git a/src/app/components/message/modals/GlobalModalManager.tsx b/src/app/components/message/modals/GlobalModalManager.tsx index 9fd4b9add..11df2aaad 100644 --- a/src/app/components/message/modals/GlobalModalManager.tsx +++ b/src/app/components/message/modals/GlobalModalManager.tsx @@ -1,3 +1,4 @@ +import { useCallback } from 'react'; import { useAtom } from 'jotai'; import { OverlayBackdrop, OverlayCenter, Box, Modal } from 'folds'; import { Overlay } from '$components/overlay-stack'; @@ -17,9 +18,10 @@ import { MobileOptionsInternal } from './Options'; export function GlobalModalManager() { const [modal, setModal] = useAtom(modalAtom); - const close = () => { + // stable so modals memoizing on it don't rebuild on every room view render + const close = useCallback(() => { setModal(null); - }; + }, [setModal]); // Forward and MobileOptions render their own back handlers via their children. useDismissOnBack( diff --git a/src/app/features/navigate/RoomSearch.tsx b/src/app/features/navigate/RoomSearch.tsx index 66de20dad..2cbde7542 100644 --- a/src/app/features/navigate/RoomSearch.tsx +++ b/src/app/features/navigate/RoomSearch.tsx @@ -158,9 +158,11 @@ export function RoomSearchModal({ const spaces = useSpaces(mx, allRoomsAtom); const directs = useDirects(mx, allRoomsAtom, mDirects); + // keyed on the ids, not on pickRoom, whose callbacks change on every host render + const eligibleRoomIds = pickRoom?.eligibleRoomIds; const eligibleSet = useMemo( - () => (pickRoom ? new Set(pickRoom.eligibleRoomIds) : null), - [pickRoom] + () => (eligibleRoomIds ? new Set(eligibleRoomIds) : null), + [eligibleRoomIds] ); const rawTopActiveRooms = useTopActiveRooms(searchRoomType, rooms, directs, spaces);