Skip to content

Commit

Permalink
fix: 대댓글 입력시 CommentForm에 Focus가 되도록 수정 (#597)
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-dong-su authored and guesung committed Jan 30, 2024
1 parent 392197e commit 8268ea8
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { useRef } from 'react';
import { useEffect, useRef } from 'react';
import { useForm } from 'react-hook-form';

import { useCommentContext } from './CommentProvider';
Expand Down Expand Up @@ -29,7 +29,13 @@ export default function CommentForm() {
});
const textareaRef = useRef<HTMLInputElement>(null);

const { handleSubmit, reset, watch, register } = hookForm;
const { handleSubmit, reset, watch, register, setFocus } = hookForm;

useEffect(() => {
if (commentType === 'reply') {
setFocus('content');
}
}, [commentType, setFocus]);

const onSubmit = ({ content }: CreateCommentRequest) => {
reset();
Expand Down

0 comments on commit 8268ea8

Please sign in to comment.