-
Notifications
You must be signed in to change notification settings - Fork 5
Fix(client): 상세 페이지 진입 시 자동으로 댓글 작성 모드에 들어가지 않도록 수정 #494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
| } | ||
|
|
||
|
|
@@ -336,7 +338,6 @@ const DetailSection = ({ postId }: DetailSectionProps) => { | |
| <> | ||
| <FeedContent postId={postId} /> | ||
| <CommentInputBox | ||
| key={focusKey} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 기존에 key로 focusKey가 잡혀 있어서 mode가 변경되었을 때 key값이 변경되니 CommentInputBox도 같이 리렌더링되는 문제가 있었어요. |
||
| value={content} | ||
| onChange={handleChange} | ||
| errorState={isErrorState} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| } | ||
| }; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
댓글 인풋이 포커스되지 않은 상태에서 사진을 먼저 선택하면, 사진만 업로드된 상태가
mode.type === 'reset'이라 인풋 포커스 시 mode가 변경되면서 상태가 초기화될 것 같습니당그래서 사진이 이미 선택된 경우에는 mode를 변경하지 않도록
if (mode.type === 'reset' && !selectedFile) {이런 식으로 조건을 추가하면 해결될 것 같은데, 더 좋은 방향이 있으면 그쪽으로 수정해주셔도 좋습니다~ 🙂
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋은 코드리뷰 감사해요! 이미지쪽 케이스를 생각을 못 했네요. 수정님 말씀대로 댓글 인풋 포커스되지 않은 상태에서 사진을 먼저 선택하고 mode가 변경되면 이미지가 사라지는 이슈가 있네요! 대댓글 모드일때도 같은 이슈가 발생했어요.
그래서 detailsection에서
이렇게 조건을 설정해서 위 케이스에서는 사용자가 작성 중인 이미지를 유지하도록 처리했습니다!
각 조건 설명: