diff --git a/src/app/features/settings/account/Profile.tsx b/src/app/features/settings/account/Profile.tsx index 5ff63c7c1..2cf6d501f 100644 --- a/src/app/features/settings/account/Profile.tsx +++ b/src/app/features/settings/account/Profile.tsx @@ -5,7 +5,6 @@ import React, { useCallback, useEffect, useMemo, - useRef, useState, } from 'react'; import { @@ -350,7 +349,6 @@ function ProfileStatus() { const [statusMsg, setStatusMsg] = useState(presence?.status ?? ''); const [clearAfter, setClearAfter] = useState('0'); const [emojiAnchor, setEmojiAnchor] = useState(); - const inputRef = useRef(null); // Initialise expiry from localStorage so timer survives page reload const [expiryTs, setExpiryTs] = useState(() => { @@ -393,25 +391,10 @@ function ProfileStatus() { ); const saving = saveState.status === AsyncStatus.Loading; - const handleEmojiSelect = useCallback( - (unicode: string) => { - const input = inputRef.current; - if (input) { - const start = input.selectionStart ?? statusMsg.length; - const end = input.selectionEnd ?? statusMsg.length; - const next = statusMsg.slice(0, start) + unicode + statusMsg.slice(end); - setStatusMsg(next); - requestAnimationFrame(() => { - input.focus(); - input.setSelectionRange(start + unicode.length, start + unicode.length); - }); - } else { - setStatusMsg((prev) => prev + unicode); - } - setEmojiAnchor(undefined); - }, - [statusMsg], - ); + const handleEmojiSelect = useCallback((unicode: string) => { + setStatusMsg((prev) => prev + unicode); + setEmojiAnchor(undefined); + }, []); const handleChange: ChangeEventHandler = (evt) => { setStatusMsg(evt.currentTarget.value); @@ -460,7 +443,6 @@ function ProfileStatus() {