diff --git a/client/src/components/Comments/Comments.tsx b/client/src/components/Comments/Comments.tsx index 7cb007c..914c3c3 100644 --- a/client/src/components/Comments/Comments.tsx +++ b/client/src/components/Comments/Comments.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useQueryClient, useMutation } from 'react-query'; import instance from 'utils/functions/axios'; import DropdownMenu from 'components/DropdownMenu/DropdownMenu'; @@ -32,7 +32,6 @@ type GreetingProps = { roleType: string; comment: CommentData; commentsUserList: number[]; - // setReRender: React.Dispatch> }; function Comments({ roleType, comment, commentsUserList }: GreetingProps) { @@ -69,6 +68,18 @@ function Comments({ roleType, comment, commentsUserList }: GreetingProps) { instance.put(path, data), ); + useEffect(() => { + if (openReCmt) { + window.addEventListener( + 'click', + () => { + setOpenReCmt(false); + }, + { once: true }, + ); + } + }); + const modifyCmtHandler = () => { setOpenEditor(!openEditor); }; @@ -226,7 +237,7 @@ function Comments({ roleType, comment, commentsUserList }: GreetingProps) { <> - + e.stopPropagation()}> { + if (openReReCmt) { + window.addEventListener( + 'click', + () => { + setOpenReReCmt(false); + }, + { once: true }, + ); + } + }); + const modifyCmtHandler = () => { setOpenEditor(!openEditor); }; @@ -239,7 +251,7 @@ function ReComments({ roleType, recomment, commentsUserList }: GreetingProps) { <> - + e.stopPropagation()}>