Skip to content

Commit

Permalink
Focus on the text area when replying
Browse files Browse the repository at this point in the history
  • Loading branch information
mybearworld committed Jun 14, 2024
1 parent 29ad46f commit bae433d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/Posts.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormEvent, useState, useRef, useCallback } from "react";
import { FormEvent, useState, useEffect, useRef, useCallback } from "react";
import * as Popover from "@radix-ui/react-popover";
import { CirclePlus, Keyboard, SendHorizontal, Smile, X } from "lucide-react";
import { twMerge } from "tailwind-merge";
Expand Down Expand Up @@ -158,6 +158,10 @@ export const EnterPostBase = (props: EnterPostBaseProps) => {
);
const [attachments, setAttachments] = useState<Attachment[]>([]);
const fileInput = useRef<HTMLInputElement | null>(null);
const textArea = useRef<HTMLTextAreaElement | null>(null);
useEffect(() => {
textArea.current?.focus?.();
}, [props.reply]);

if (!credentials) {
return <></>;
Expand Down Expand Up @@ -232,6 +236,7 @@ export const EnterPostBase = (props: EnterPostBaseProps) => {
return (
<form onSubmit={handlePost} className={twMerge("w-full")}>
<Textarea
ref={textArea}
value={postContent}
onChange={(e) => setPostContent(e.currentTarget.value)}
onInput={() => sendTyping(props.chat)}
Expand Down

0 comments on commit bae433d

Please sign in to comment.