diff --git a/frontend/components/table-category/CategoryValueManagerTree.tsx b/frontend/components/table-category/CategoryValueManagerTree.tsx index 07965ce2..b3329a41 100644 --- a/frontend/components/table-category/CategoryValueManagerTree.tsx +++ b/frontend/components/table-category/CategoryValueManagerTree.tsx @@ -6,7 +6,7 @@ * - 체크박스를 통한 다중 선택 및 일괄 삭제 지원 */ -import React, { useState, useEffect, useCallback, useMemo } from "react"; +import React, { useState, useEffect, useCallback, useMemo, useRef } from "react"; import { ChevronRight, ChevronDown, @@ -291,6 +291,10 @@ export const CategoryValueManagerTree: React.FC = const [editingValue, setEditingValue] = useState(null); const [deletingValue, setDeletingValue] = useState(null); + // 추가 모달 input ref + const addNameRef = useRef(null); + const addDescRef = useRef(null); + // 폼 상태 const [formData, setFormData] = useState({ valueCode: "", @@ -508,7 +512,15 @@ export const CategoryValueManagerTree: React.FC = const response = await createCategoryValue(input); if (response.success) { toast.success("카테고리가 추가되었습니다"); - setIsAddModalOpen(false); + // 폼 초기화 (모달은 닫지 않고 연속 입력) + setFormData((prev) => ({ + ...prev, + valueCode: "", + valueLabel: "", + description: "", + color: "", + })); + setTimeout(() => addNameRef.current?.focus(), 50); // 기존 펼침 상태 유지하면서 데이터 새로고침 await loadTree(true); // 부모 노드만 펼치기 (하위 추가 시) @@ -746,9 +758,17 @@ export const CategoryValueManagerTree: React.FC = 이름 * setFormData({ ...formData, valueLabel: e.target.value })} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault(); + e.stopPropagation(); + addDescRef.current?.focus(); + } + }} placeholder="카테고리 이름을 입력하세요" className="h-9 text-sm" /> @@ -759,9 +779,17 @@ export const CategoryValueManagerTree: React.FC = 설명 setFormData({ ...formData, description: e.target.value })} + onKeyDown={(e) => { + if (e.key === "Enter") { + e.preventDefault(); + e.stopPropagation(); + handleAdd(); + } + }} placeholder="선택 사항" className="h-9 text-sm" /> @@ -784,7 +812,7 @@ export const CategoryValueManagerTree: React.FC = onClick={() => setIsAddModalOpen(false)} className="h-9 flex-1 text-sm sm:flex-none" > - 취소 + 닫기