mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
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:
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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user