diff --git a/frontend/components/screen/config-panels/ButtonConfigPanel.tsx b/frontend/components/screen/config-panels/ButtonConfigPanel.tsx index 05922dbe..2cb1e3ce 100644 --- a/frontend/components/screen/config-panels/ButtonConfigPanel.tsx +++ b/frontend/components/screen/config-panels/ButtonConfigPanel.tsx @@ -27,6 +27,24 @@ interface ScreenOption { export const ButtonConfigPanel: React.FC = ({ component, onUpdateProperty }) => { const config = component.componentConfig || {}; + + // 로컬 상태 관리 (실시간 입력 반영) + const [localInputs, setLocalInputs] = useState({ + text: config.text || "버튼", + modalTitle: config.action?.modalTitle || "", + editModalTitle: config.action?.editModalTitle || "", + editModalDescription: config.action?.editModalDescription || "", + targetUrl: config.action?.targetUrl || "", + }); + + const [localSelects, setLocalSelects] = useState({ + variant: config.variant || "default", + size: config.size || "default", + actionType: config.action?.type || "save", + modalSize: config.action?.modalSize || "md", + editMode: config.action?.editMode || "modal", + }); + const [screens, setScreens] = useState([]); const [screensLoading, setScreensLoading] = useState(false); const [modalScreenOpen, setModalScreenOpen] = useState(false); @@ -34,6 +52,36 @@ export const ButtonConfigPanel: React.FC = ({ component, const [modalSearchTerm, setModalSearchTerm] = useState(""); const [navSearchTerm, setNavSearchTerm] = useState(""); + // 컴포넌트 변경 시 로컬 상태 동기화 + useEffect(() => { + setLocalInputs({ + text: config.text || "버튼", + modalTitle: config.action?.modalTitle || "", + editModalTitle: config.action?.editModalTitle || "", + editModalDescription: config.action?.editModalDescription || "", + targetUrl: config.action?.targetUrl || "", + }); + + setLocalSelects({ + variant: config.variant || "default", + size: config.size || "default", + actionType: config.action?.type || "save", + modalSize: config.action?.modalSize || "md", + editMode: config.action?.editMode || "modal", + }); + }, [ + config.text, + config.variant, + config.size, + config.action?.type, + config.action?.modalTitle, + config.action?.modalSize, + config.action?.editMode, + config.action?.editModalTitle, + config.action?.editModalDescription, + config.action?.targetUrl, + ]); + // 화면 목록 가져오기 useEffect(() => { const fetchScreens = async () => { @@ -86,8 +134,12 @@ export const ButtonConfigPanel: React.FC = ({ component, onUpdateProperty("componentConfig.text", e.target.value)} + value={localInputs.text} + onChange={(e) => { + const newValue = e.target.value; + setLocalInputs((prev) => ({ ...prev, text: newValue })); + onUpdateProperty("componentConfig.text", newValue); + }} placeholder="버튼 텍스트를 입력하세요" /> @@ -95,8 +147,11 @@ export const ButtonConfigPanel: React.FC = ({ component,
onUpdateProperty("componentConfig.size", value)} + value={localSelects.size} + onValueChange={(value) => { + setLocalSelects((prev) => ({ ...prev, size: value })); + onUpdateProperty("componentConfig.size", value); + }} > @@ -133,25 +191,27 @@ export const ButtonConfigPanel: React.FC = ({ component,
+ value={localInputs.modalTitle} + onChange={(e) => { + const newValue = e.target.value; + setLocalInputs((prev) => ({ ...prev, modalTitle: newValue })); onUpdateProperty("componentConfig.action", { ...config.action, - modalTitle: e.target.value, - }) - } + modalTitle: newValue, + }); + }} />
+ value={localSelects.editMode} + onValueChange={(value) => { + setLocalSelects((prev) => ({ ...prev, editMode: value })); onUpdateProperty("componentConfig.action", { ...config.action, editMode: value, - }) - } + }); + }} > @@ -394,16 +458,17 @@ export const ButtonConfigPanel: React.FC = ({ component,
- {config.action?.editMode === "modal" && ( + {localSelects.editMode === "modal" && ( <>
{ const newValue = e.target.value; + setLocalInputs((prev) => ({ ...prev, editModalTitle: newValue })); onUpdateProperty("componentConfig.action", { ...config.action, editModalTitle: newValue, @@ -420,9 +485,10 @@ export const ButtonConfigPanel: React.FC = ({ component, { const newValue = e.target.value; + setLocalInputs((prev) => ({ ...prev, editModalDescription: newValue })); onUpdateProperty("componentConfig.action", { ...config.action, editModalDescription: newValue, @@ -437,13 +503,14 @@ export const ButtonConfigPanel: React.FC = ({ component,
+ value={localInputs.targetUrl} + onChange={(e) => { + const newValue = e.target.value; + setLocalInputs((prev) => ({ ...prev, targetUrl: newValue })); onUpdateProperty("componentConfig.action", { ...config.action, - targetUrl: e.target.value, - }) - } + targetUrl: newValue, + }); + }} />

URL을 입력하면 화면 선택보다 우선 적용됩니다

@@ -564,7 +633,7 @@ export const ButtonConfigPanel: React.FC = ({ component,

🔧 고급 기능

-

버튼 액션과 함께 실행될 추가 기능을 설정합니다

+

버튼 액션과 함께 실행될 추가 기능을 설정합니다