From 74d61aaf453e4e9c2d25700bbd75ee199a936385 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Tue, 30 Dec 2025 16:05:04 +0900 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=EC=83=81=EC=84=B8=20=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=A7=88=EC=9A=B4=ED=8A=B8=20=EC=8B=9C=20?= =?UTF-8?q?reset=20=EB=AA=A8=EB=93=9C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/comment-input-box/comment-input-box.tsx | 10 +++++++++- .../widgets/community/context/input-mode-context.tsx | 9 ++------- .../community/hooks/create-input-mode-reducer.ts | 8 +++++++- .../src/widgets/community/types/input-box-type.ts | 2 ++ 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/apps/client/src/widgets/community/components/comment-input-box/comment-input-box.tsx b/apps/client/src/widgets/community/components/comment-input-box/comment-input-box.tsx index 4d9998d5..4666861b 100644 --- a/apps/client/src/widgets/community/components/comment-input-box/comment-input-box.tsx +++ b/apps/client/src/widgets/community/components/comment-input-box/comment-input-box.tsx @@ -41,6 +41,13 @@ const CommentInputBox = ({ const { openModal, closeModal } = useModal(); const replyCreateMode = mode.type === 'reply' && mode.action === 'create'; + + const handleFocus = () => { + if (mode.type === 'reset') { + dispatch({ type: 'COMMENT_CREATE' }); + } + }; + useClickOutside( wrapperRef, () => dispatch({ type: 'RESET' }), @@ -137,10 +144,11 @@ const CommentInputBox = ({
{ - dispatch({ type: 'RESET' }); - }, [postId]); const value = useMemo(() => ({ mode, dispatch }), [mode]); return ( diff --git a/apps/client/src/widgets/community/hooks/create-input-mode-reducer.ts b/apps/client/src/widgets/community/hooks/create-input-mode-reducer.ts index 7c263449..3283f869 100644 --- a/apps/client/src/widgets/community/hooks/create-input-mode-reducer.ts +++ b/apps/client/src/widgets/community/hooks/create-input-mode-reducer.ts @@ -15,6 +15,12 @@ export const createInputModeReducer = ({ action, }: ComposeModeReducerType): InputBoxMode => { switch (action.type) { + case 'COMMENT_CREATE': + return { + type: 'comment', + action: 'create', + postId, + } as const; case 'COMMENT_EDIT': return { type: 'comment', @@ -68,6 +74,6 @@ export const createInputModeReducer = ({ case 'RESET': default: - return { type: 'comment', action: 'create', postId } as const; + return { type: 'reset', action: 'reset' } as const; } }; diff --git a/apps/client/src/widgets/community/types/input-box-type.ts b/apps/client/src/widgets/community/types/input-box-type.ts index 3714f415..d121f1b4 100644 --- a/apps/client/src/widgets/community/types/input-box-type.ts +++ b/apps/client/src/widgets/community/types/input-box-type.ts @@ -1,6 +1,7 @@ import { Image } from '@shared/types/type.ts'; export type InputBoxMode = + | { type: 'reset'; action: 'reset' } | { type: 'comment'; action: 'create'; postId: string; images?: Image[] } | { type: 'comment'; @@ -24,6 +25,7 @@ export type InputBoxMode = }; export type ReducerAction = + | { type: 'COMMENT_CREATE' } | { type: 'COMMENT_EDIT'; commentId: number; From 7028710f7a930e6d96da725ea41f962af90ed248 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Tue, 30 Dec 2025 16:17:15 +0900 Subject: [PATCH 2/5] =?UTF-8?q?fix:=20useControlledInputBox=20=ED=9B=85=20?= =?UTF-8?q?=EB=8B=A8=EC=88=9C=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/hooks/use-controll-input-box.ts | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/apps/client/src/widgets/community/hooks/use-controll-input-box.ts b/apps/client/src/widgets/community/hooks/use-controll-input-box.ts index 8318b7f7..7e3c490e 100644 --- a/apps/client/src/widgets/community/hooks/use-controll-input-box.ts +++ b/apps/client/src/widgets/community/hooks/use-controll-input-box.ts @@ -1,28 +1,19 @@ -import { useEffect, useRef, useState } from 'react'; +import { useEffect, useState } from 'react'; import { InputBoxMode } from '@widgets/community/types/input-box-type'; import { LIMIT_SHORT_TEXT } from '@shared/constants/text-limits'; export const useControlledInputBox = (mode: InputBoxMode) => { - const [content, setContent] = useState( - 'initialContent' in mode ? mode.initialContent : '', - ); - const prevModeRef = useRef(mode); + const [content, setContent] = useState(''); - useEffect(() => { - const isStillCreatingMode = - prevModeRef.current.action === 'create' && mode.action === 'create'; - const typeChanged = prevModeRef.current.type !== mode.type; - - prevModeRef.current = mode; + const initialContent = 'initialContent' in mode ? mode.initialContent : null; - if (isStillCreatingMode && typeChanged) { - return; + useEffect(() => { + if (initialContent !== null) { + setContent(initialContent); } - - setContent('initialContent' in mode ? mode.initialContent : ''); - }, [mode]); + }, [initialContent]); const handleChange = (e: React.ChangeEvent) => { const next = e.target.value; @@ -32,7 +23,7 @@ export const useControlledInputBox = (mode: InputBoxMode) => { }; const reset = () => { - setContent('initialContent' in mode ? mode.initialContent : ''); + setContent(''); }; return { content, handleChange, reset }; From e3b4693841977ca8d3d99c84b32e0cd639f4c4a1 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Thu, 1 Jan 2026 01:27:54 +0900 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=B3=B4=EC=A1=B4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/detail-section/detail-section.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/apps/client/src/widgets/community/components/detail-section/detail-section.tsx b/apps/client/src/widgets/community/components/detail-section/detail-section.tsx index 4c3c4f5e..713a33f4 100644 --- a/apps/client/src/widgets/community/components/detail-section/detail-section.tsx +++ b/apps/client/src/widgets/community/components/detail-section/detail-section.tsx @@ -31,10 +31,7 @@ const DetailSection = ({ postId }: DetailSectionProps) => { const queryClient = useQueryClient(); useEffect(() => { - const isStillCreatingMode = - prevModeRef.current.action === 'create' && mode.action === 'create'; - const typeChanged = prevModeRef.current.type !== mode.type; - + const prev = prevModeRef.current; prevModeRef.current = mode; if (mode.type === 'comment' && mode.action === 'edit') { @@ -72,7 +69,12 @@ const DetailSection = ({ postId }: DetailSectionProps) => { return; } - if (isStillCreatingMode && typeChanged) { + const shouldPreserveImage = + (prev.type === 'reset' && mode.action === 'create') || + (prev.action === 'create' && mode.type === 'reset') || + (prev.action === 'create' && mode.action === 'create'); + + if (shouldPreserveImage) { return; } From 7ddd3e2807623760a6f662caf6ccc12852c3e849 Mon Sep 17 00:00:00 2001 From: jeonghoon11 Date: Thu, 1 Jan 2026 01:32:46 +0900 Subject: [PATCH 4/5] =?UTF-8?q?fix:=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20=EA=B9=9C=EB=B9=A1?= =?UTF-8?q?=EC=9E=84=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community/components/detail-section/detail-section.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/client/src/widgets/community/components/detail-section/detail-section.tsx b/apps/client/src/widgets/community/components/detail-section/detail-section.tsx index 713a33f4..7089cb5d 100644 --- a/apps/client/src/widgets/community/components/detail-section/detail-section.tsx +++ b/apps/client/src/widgets/community/components/detail-section/detail-section.tsx @@ -338,7 +338,6 @@ const DetailSection = ({ postId }: DetailSectionProps) => { <> Date: Sun, 4 Jan 2026 22:32:07 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20Input=20autoFocus=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/comment-input-box/comment-input-box.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/client/src/widgets/community/components/comment-input-box/comment-input-box.tsx b/apps/client/src/widgets/community/components/comment-input-box/comment-input-box.tsx index 4666861b..d659e7df 100644 --- a/apps/client/src/widgets/community/components/comment-input-box/comment-input-box.tsx +++ b/apps/client/src/widgets/community/components/comment-input-box/comment-input-box.tsx @@ -144,7 +144,7 @@ const CommentInputBox = ({