From 017ba4ff3643c6b19c5644af480cc4161d025fe1 Mon Sep 17 00:00:00 2001 From: hazre Date: Mon, 2 Mar 2026 19:01:33 +0100 Subject: [PATCH] fix: focus nickname input imperatively in user chips --- src/app/components/user-profile/UserChips.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/components/user-profile/UserChips.tsx b/src/app/components/user-profile/UserChips.tsx index f2df0207..950474a9 100644 --- a/src/app/components/user-profile/UserChips.tsx +++ b/src/app/components/user-profile/UserChips.tsx @@ -2,6 +2,7 @@ import { KeyboardEventHandler, MouseEventHandler, useCallback, + useEffect, useMemo, useRef, useState, @@ -447,6 +448,8 @@ export function IgnoredUserAlert() { export function OptionsChip({ userId }: { userId: string }) { const mx = useMatrixClient(); const [cords, setCords] = useState(); + const [editingNick, setEditingNick] = useState(false); + const nickInputRef = useRef(null); const open: MouseEventHandler = (evt) => { setCords(evt.currentTarget.getBoundingClientRect()); @@ -471,8 +474,12 @@ export function OptionsChip({ userId }: { userId: string }) { const currentNick = useNickname(userId); const setNickname = useSetNickname(); - const [editingNick, setEditingNick] = useState(false); - const nickInputRef = useRef(null); + + useEffect(() => { + if (editingNick) { + nickInputRef.current?.focus(); + } + }, [editingNick]); const handleSaveNick = () => { const value = nickInputRef.current?.value ?? ''; @@ -513,7 +520,6 @@ export function OptionsChip({ userId }: { userId: string }) { Nickname