fix(forward): keep search results from being dropped mid-typing

useAsyncSearch clears its result whenever the list identity changes. In the
room picker that list is derived from pickRoom, whose identity churned on
every GlobalModalManager render, so any room activity wiped the search and
fell back to recent rooms.

Key eligibleSet on the room ids instead of the pickRoom object, and make
close stable.
This commit is contained in:
Erwan Leboucher committed 2026-08-16 22:54:25 +02:00
1 parent 06042b08ce
commit 38dcaa14f7
2 files changed
+8 -4

No files matched your search

@@ -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(
+4 -2
View File
@@ -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);