Skip to content

Commit

Permalink
fix: typing in edit textarea moves cursor to end
Browse files Browse the repository at this point in the history
  • Loading branch information
danerieber committed Jun 1, 2024
1 parent e47681a commit 332beb4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions components/ChatMessageElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import remarkGemoji from "remark-gemoji";
import { Edit, Reply, Verified } from "@mui/icons-material";
import { Tooltip } from "@nextui-org/tooltip";
import rehypeExternalLinks from "rehype-external-links";
import { useEffect, useRef, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
import { Button, ButtonGroup } from "@nextui-org/button";
import { Textarea } from "@nextui-org/input";
import mentions from "@/lib/mentions";
Expand Down Expand Up @@ -65,11 +65,11 @@ export default function ChatMessageElement({
if (isEditing) {
textareaRef.current?.focus();
textareaRef.current?.setSelectionRange(
editedContent.length,
editedContent.length,
textareaRef.current?.value.length,
textareaRef.current?.value.length,
);
}
}, [editedContent.length, isEditing]);
}, [isEditing]);

function editMessage() {
if (editedContent !== content) {
Expand Down

0 comments on commit 332beb4

Please sign in to comment.