Skip to content

Commit 1a24350

Browse files
authored
hotfix: 기술스택 모달 생성 제한 (#381)
2 parents ff3f2db + 90c0e82 commit 1a24350

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

frontend/src/features/widgets/techStack/hooks/techStackWidget/useTechStack.ts

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { TechStackWidgetData } from '@/common/types/widgetData';
55
import { useWidgetIdAndType } from '@/common/components/widgetFrame/context/WidgetContext';
66
import { useWorkspaceWidgetStore } from '@/common/store/workspace';
77
import { useShallow } from 'zustand/react/shallow';
8+
import { useTechStackModalStore } from '../../store/techStackModalStore';
89
import {
910
updateArrayContentAction,
1011
updateSelectorPickAction,
@@ -55,7 +56,27 @@ export function useTechStack() {
5556
[widgetId, type],
5657
);
5758

58-
const [isModalOpen, setIsModalOpen] = useState(false);
59+
const activeWidgetId = useTechStackModalStore(
60+
(state) => state.activeWidgetId,
61+
);
62+
const openModal = useTechStackModalStore((state) => state.openModal);
63+
const closeModal = useTechStackModalStore((state) => state.closeModal);
64+
65+
// 이 모달이 열려있는지 확인
66+
const isModalOpen = activeWidgetId === widgetId;
67+
68+
const handleOpenModal = useCallback(() => {
69+
// 다른 모달이 열려있으면 동작하지 않음 (Blocking)
70+
if (activeWidgetId && activeWidgetId !== widgetId) {
71+
return;
72+
}
73+
74+
openModal(widgetId);
75+
}, [widgetId, openModal, activeWidgetId]);
76+
77+
const handleCloseModal = useCallback(() => {
78+
closeModal();
79+
}, [closeModal]);
5980

6081
const setSelectedTechStacks = (value: React.SetStateAction<TechStack[]>) => {
6182
let newItems: TechStack[];
@@ -104,8 +125,8 @@ export function useTechStack() {
104125
handleCreateSubject,
105126
actions: {
106127
setSelectedTechStacks,
107-
openModal: () => setIsModalOpen(true),
108-
closeModal: () => setIsModalOpen(false),
128+
openModal: handleOpenModal,
129+
closeModal: handleCloseModal,
109130
},
110131
};
111132
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { create } from 'zustand';
2+
3+
interface TechStackModalState {
4+
activeWidgetId: string | null;
5+
openModal: (widgetId: string) => void;
6+
closeModal: () => void;
7+
}
8+
9+
export const useTechStackModalStore = create<TechStackModalState>((set) => ({
10+
activeWidgetId: null,
11+
openModal: (widgetId) => set({ activeWidgetId: widgetId }),
12+
closeModal: () => set({ activeWidgetId: null }),
13+
}));

0 commit comments

Comments
 (0)