fix(reply modal): cursor would move to end of text while replying

This commit is contained in:
Tom (plebeius.eth)
2024-07-22 12:29:05 +02:00
parent 2edc7b9f4d
commit 6430607363
+7 -2
View File
@@ -86,11 +86,16 @@ const ReplyModal = ({ closeModal, parentCid, scrollY }: ReplyModalProps) => {
if (ref) {
textRef.current = ref;
!isMobile && ref.focus();
const len = ref.value.length;
ref.setSelectionRange(len, len);
}
};
useEffect(() => {
if (textRef.current) {
const len = textRef.current.value.length;
textRef.current.setSelectionRange(len, len);
}
}, []);
const contentPrefix = `c/${parentCid && Plebbit.getShortCid(parentCid)}\n`;
const handleContentInput = (e: React.ChangeEvent<HTMLTextAreaElement>) => {