Skip to content

Commit

Permalink
feat: 초대 모달이 켜지면, input으로 focus이동하게 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyonun321 committed Dec 2, 2024
1 parent 8f1980e commit ab47668
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion client/src/components/modal/InviteModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// InviteModal.tsx
import { useState } from "react";
import { useState, useEffect, useRef } from "react";
import { modalContentContainer, titleText, descriptionText, emailInput } from "./InviteModal.style";
import { Modal } from "./modal";

Expand All @@ -11,6 +11,13 @@ interface InviteModalProps {

export const InviteModal = ({ isOpen, onClose, onInvite }: InviteModalProps) => {
const [email, setEmail] = useState("");
const inputRef = useRef<HTMLInputElement>(null);

useEffect(() => {
if (isOpen) {
inputRef.current?.focus();
}
}, [isOpen]);

const handleInvite = () => {
onInvite(email);
Expand All @@ -30,6 +37,7 @@ export const InviteModal = ({ isOpen, onClose, onInvite }: InviteModalProps) =>
<h2 className={titleText}>워크스페이스 초대</h2>
<p className={descriptionText}>초대할 사용자의 이메일을 입력해주세요</p>
<input
ref={inputRef}
className={emailInput}
onChange={(e) => setEmail(e.target.value)}
placeholder="이메일 주소 입력"
Expand Down

0 comments on commit ab47668

Please sign in to comment.