From ad64cff26db0652abe89967efba7f96c7b1f6e60 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sun, 22 Mar 2026 21:05:20 +0200 Subject: [PATCH] More UserSearch useEffect stabilization attempts --- app/components/elements/UserSearch.tsx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/components/elements/UserSearch.tsx b/app/components/elements/UserSearch.tsx index 045754a10..6f95f4d4f 100644 --- a/app/components/elements/UserSearch.tsx +++ b/app/components/elements/UserSearch.tsx @@ -66,16 +66,19 @@ export const UserSearch = React.forwardRef(function UserSearch< }; // clear if selected user is not in the new filtered items + const itemsJoined = items.map((user) => user.id).join(","); React.useEffect(() => { + const ids = itemsJoined.split(",").map(Number); + if ( selectedKey && selectedKey !== initialUserId && - !items.some((user) => user.id === selectedKey) + !ids.includes(selectedKey) ) { setSelectedKey(null); onChange?.(null); } - }, [items, selectedKey, onChange, initialUserId]); + }, [itemsJoined, selectedKey, onChange, initialUserId]); return (