diff --git a/frontend/techpick/package.json b/frontend/techpick/package.json index 8bbf250fd..051adc9d2 100644 --- a/frontend/techpick/package.json +++ b/frontend/techpick/package.json @@ -35,7 +35,6 @@ "es-toolkit": "^1.26.1", "immer": "^10.1.1", "ky": "^1.7.2", - "lodash": "^4.17.21", "lucide-react": "^0.447.0", "next": "14.2.9", "randomcolor": "^0.6.2", @@ -48,6 +47,7 @@ "react-dom": "^18", "react-hot-toast": "^2.4.1", "react-spinners": "^0.14.1", + "react-textarea-autosize": "^8.5.5", "react-virtualized-auto-sizer": "^1.0.24", "react-window": "^1.8.10", "react-window-infinite-loader": "^1.0.9", @@ -74,7 +74,6 @@ "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", "@types/dompurify": "^3", - "@types/lodash": "^4", "@types/node": "^22.5.4", "@types/randomcolor": "^0.5.9", "@types/react": "^18", diff --git a/frontend/techpick/src/components/PickListViewer/PickDndListItem.tsx b/frontend/techpick/src/components/PickListViewer/PickDndListItem.tsx index 63b796fa0..c5221cd60 100644 --- a/frontend/techpick/src/components/PickListViewer/PickDndListItem.tsx +++ b/frontend/techpick/src/components/PickListViewer/PickDndListItem.tsx @@ -22,7 +22,7 @@ export function PickDndListItem({ pickInfo }: PickViewDnDItemComponentProps) { setSelectedPickIdList, isDragging, } = usePickStore(); - const { setCurrentPickIdToNull } = useUpdatePickStore(); + const { setCurrentUpdateTitlePickIdToNull } = useUpdatePickStore(); const { id: pickId, parentFolderId } = pickInfo; const isSelected = selectedPickIdList.includes(pickId); const { @@ -75,7 +75,7 @@ export function PickDndListItem({ pickInfo }: PickViewDnDItemComponentProps) { return; } - setCurrentPickIdToNull(); + setCurrentUpdateTitlePickIdToNull(); selectSinglePick(pickId); }; diff --git a/frontend/techpick/src/components/PickListViewer/PickListItem.tsx b/frontend/techpick/src/components/PickListViewer/PickListItem.tsx index e0715be9f..5bf487267 100644 --- a/frontend/techpick/src/components/PickListViewer/PickListItem.tsx +++ b/frontend/techpick/src/components/PickListViewer/PickListItem.tsx @@ -26,11 +26,11 @@ export function PickListItem({ pickInfo }: PickViewItemComponentProps) { const { updatePickInfo } = usePickStore(); const { openUrlInNewTab } = useOpenUrlInNewTab(link.url); const { - currentUpdatePickId, - setCurrentPickIdToNull, - setCurrentUpdatePickId, + currentUpdateTitlePickId, + setCurrentUpdateTitlePickIdToNull, + setCurrentUpdateTitlePickId, } = useUpdatePickStore(); - const isUpdateTitle = currentUpdatePickId === pickInfo.id; + const isUpdateTitle = currentUpdateTitlePickId === pickInfo.id; return (
@@ -50,17 +50,17 @@ export function PickListItem({ pickInfo }: PickViewItemComponentProps) { ...pickInfo, title: newTitle, }); - setCurrentPickIdToNull(); + setCurrentUpdateTitlePickIdToNull(); }} onClickOutSide={() => { - setCurrentPickIdToNull(); + setCurrentUpdateTitlePickIdToNull(); }} /> ) : (
{ - setCurrentUpdatePickId(pickInfo.id); + setCurrentUpdateTitlePickId(pickInfo.id); event.stopPropagation(); }} role="button" diff --git a/frontend/techpick/src/components/PickListViewer/PickTitleInput.tsx b/frontend/techpick/src/components/PickListViewer/PickTitleInput.tsx index 381e0ac30..f586b2995 100644 --- a/frontend/techpick/src/components/PickListViewer/PickTitleInput.tsx +++ b/frontend/techpick/src/components/PickListViewer/PickTitleInput.tsx @@ -29,8 +29,6 @@ export function PickTitleInput({ useEffect( function detectOutsideClick() { const handleClickOutside = (event: MouseEvent) => { - console.log('handleClickOutside work!'); - if ( containerRef.current && !containerRef.current.contains(event.target as Node) diff --git a/frontend/techpick/src/components/PickRecord/PickDraggableRecord.tsx b/frontend/techpick/src/components/PickRecord/PickDraggableRecord.tsx index 06d29b939..4b0113fc6 100644 --- a/frontend/techpick/src/components/PickRecord/PickDraggableRecord.tsx +++ b/frontend/techpick/src/components/PickRecord/PickDraggableRecord.tsx @@ -21,7 +21,11 @@ export function PickDraggableRecord({ setSelectedPickIdList, isDragging, } = usePickStore(); - const { setCurrentPickIdToNull } = useUpdatePickStore(); + const { + setCurrentUpdateTitlePickIdToNull, + currentUpdateTitlePickId, + currentUpdateTagPickId, + } = useUpdatePickStore(); const { id: pickId, parentFolderId } = pickInfo; const isSelected = selectedPickIdList.includes(pickId); const { @@ -38,6 +42,9 @@ export function PickDraggableRecord({ type: 'pick', parentFolderId: parentFolderId, }, + disabled: + currentUpdateTitlePickId === pickInfo.id || + currentUpdateTagPickId === pickInfo.id, }); const pickElementId = `pickId-${pickId}`; @@ -74,7 +81,7 @@ export function PickDraggableRecord({ return; } - setCurrentPickIdToNull(); + setCurrentUpdateTitlePickIdToNull(); selectSinglePick(pickId); }; diff --git a/frontend/techpick/src/components/PickRecord/PickRecord.tsx b/frontend/techpick/src/components/PickRecord/PickRecord.tsx index 5e3bf8d24..5b06a760f 100644 --- a/frontend/techpick/src/components/PickRecord/PickRecord.tsx +++ b/frontend/techpick/src/components/PickRecord/PickRecord.tsx @@ -31,12 +31,12 @@ export function PickRecord({ pickInfo }: PickViewItemComponentProps) { const { updatePickInfo } = usePickStore(); const { openUrlInNewTab } = useOpenUrlInNewTab(link.url); const { - currentUpdatePickId, - setCurrentPickIdToNull, - setCurrentUpdatePickId, + currentUpdateTitlePickId, + setCurrentUpdateTitlePickId, + setCurrentUpdateTitlePickIdToNull, } = useUpdatePickStore(); const [isHovered, setIsHovered] = useState(false); - const isUpdateTitle = currentUpdatePickId === pickInfo.id; + const isUpdateTitle = currentUpdateTitlePickId === pickInfo.id; const { isDragging } = usePickStore(); const filteredSelectedTagList: TagType[] = []; @@ -57,7 +57,7 @@ export function PickRecord({ pickInfo }: PickViewItemComponentProps) {
{link.imageUrl ? ( - + ) : (
)} @@ -72,7 +72,17 @@ export function PickRecord({ pickInfo }: PickViewItemComponentProps) { - {isUpdateTitle ? ( +
{ + setCurrentUpdateTitlePickId(pickInfo.id); + event.stopPropagation(); + }} + role="button" + > + {pick.title} +
+ {isUpdateTitle && ( { @@ -80,23 +90,12 @@ export function PickRecord({ pickInfo }: PickViewItemComponentProps) { ...pickInfo, title: newTitle, }); - setCurrentPickIdToNull(); + setCurrentUpdateTitlePickIdToNull(); }} onClickOutSide={() => { - setCurrentPickIdToNull(); + setCurrentUpdateTitlePickIdToNull(); }} /> - ) : ( -
{ - setCurrentUpdatePickId(pickInfo.id); - event.stopPropagation(); - }} - role="button" - > - {pick.title} -
)}
diff --git a/frontend/techpick/src/components/PickRecord/PickRecordOverlay.tsx b/frontend/techpick/src/components/PickRecord/PickRecordOverlay.tsx index 6445403a8..b90cb1971 100644 --- a/frontend/techpick/src/components/PickRecord/PickRecordOverlay.tsx +++ b/frontend/techpick/src/components/PickRecord/PickRecordOverlay.tsx @@ -30,12 +30,12 @@ export function PickRecordOverlay({ pickInfo }: PickViewItemComponentProps) { const { updatePickInfo } = usePickStore(); const { openUrlInNewTab } = useOpenUrlInNewTab(link.url); const { - currentUpdatePickId, - setCurrentPickIdToNull, - setCurrentUpdatePickId, + currentUpdateTitlePickId, + setCurrentUpdateTitlePickId, + setCurrentUpdateTitlePickIdToNull, } = useUpdatePickStore(); - const isUpdateTitle = currentUpdatePickId === pickInfo.id; + const isUpdateTitle = currentUpdateTitlePickId === pickInfo.id; const filteredSelectedTagList: TagType[] = []; @@ -72,17 +72,17 @@ export function PickRecordOverlay({ pickInfo }: PickViewItemComponentProps) { ...pickInfo, title: newTitle, }); - setCurrentPickIdToNull(); + setCurrentUpdateTitlePickIdToNull(); }} onClickOutSide={() => { - setCurrentPickIdToNull(); + setCurrentUpdateTitlePickIdToNull(); }} /> ) : (
{ - setCurrentUpdatePickId(pickInfo.id); + setCurrentUpdateTitlePickId(pickInfo.id); event.stopPropagation(); }} role="button" diff --git a/frontend/techpick/src/components/PickRecord/PickRecordTitleInput.tsx b/frontend/techpick/src/components/PickRecord/PickRecordTitleInput.tsx index da0aa6d23..6ac968997 100644 --- a/frontend/techpick/src/components/PickRecord/PickRecordTitleInput.tsx +++ b/frontend/techpick/src/components/PickRecord/PickRecordTitleInput.tsx @@ -1,9 +1,11 @@ -'use client'; - import { useCallback, useEffect, useRef } from 'react'; import type { KeyboardEvent } from 'react'; +import TextareaAutosize from 'react-textarea-autosize'; import { isEmptyString } from '@/utils'; -import { pickTitleInputStyle } from './pickRecordTitleInput.css'; +import { + pickTitleInputStyle, + pickRecordTitleInputLayoutStyle, +} from './pickRecordTitleInput.css'; export function PickRecordTitleInput({ onSubmit, @@ -54,21 +56,30 @@ export function PickRecordTitleInput({ ); useEffect( - function initializeFolderInput() { + function initializePickRecordTitleInput() { if (textAreaRef.current) { textAreaRef.current.value = initialValue; - // 타이밍 이슈 탓으로 인해 setTimeout 사용 - setTimeout(() => textAreaRef.current?.focus(), 0); + textAreaRef.current?.focus(); + // 커서를 텍스트의 끝으로 이동 + textAreaRef.current?.setSelectionRange( + initialValue.length, + initialValue.length + ); } }, [initialValue] ); return ( -
e.stopPropagation()}> -