Skip to content

Commit 5c29a14

Browse files
committed
feat: 선택된 스티커가 없을 때에는 context menu 활성화 되지 않도록 구현
1 parent 1b25cb2 commit 5c29a14

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

apps/web/src/components/(with-side-bar)/topic/context-menu-provider.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010

1111
interface ContextMenuProviderProps {
1212
children: React.ReactNode;
13+
isTriggerDisabled: boolean;
1314
}
1415

1516
const isMac = typeof window !== "undefined" && /Mac|iPhone|iPad|iPod/.test(navigator.userAgent);
@@ -19,7 +20,10 @@ const onEscapeContextMenu = () => {
1920
document.dispatchEvent(escEvent);
2021
};
2122

22-
export default function ContextMenuProvider({ children }: ContextMenuProviderProps) {
23+
export default function ContextMenuProvider({
24+
children,
25+
isTriggerDisabled,
26+
}: ContextMenuProviderProps) {
2327
const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
2428

2529
const onDuplicate = () => {
@@ -101,7 +105,9 @@ export default function ContextMenuProvider({ children }: ContextMenuProviderPro
101105

102106
return (
103107
<ContextMenu onOpenChange={setIsContextMenuOpen}>
104-
<ContextMenuTrigger asChild>{children}</ContextMenuTrigger>
108+
<ContextMenuTrigger asChild disabled={isTriggerDisabled}>
109+
{children}
110+
</ContextMenuTrigger>
105111
<ContextMenuContent className="min-w-60 rounded-2xl bg-[#333] p-5 text-white">
106112
<ContextMenuItem
107113
className="flex items-center justify-between rounded-xl px-4 py-1 focus:bg-[#7E4ED7] focus:text-white"

apps/web/src/components/(with-side-bar)/topic/react-flow-canvas.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ function FlowCanvas({
7171
const { screenToFlowPosition } = useReactFlow();
7272
const { mutateAsync: createContent } = useCreateContent(id);
7373

74+
const isTriggerDisabled = selectedNodeIds.length === 0;
75+
7476
const nodeTypes: NodeTypes = useMemo(
7577
() => ({
7678
custom: (props: NodeProps) => (
@@ -112,7 +114,7 @@ function FlowCanvas({
112114
};
113115

114116
return (
115-
<ContextMenuProvider>
117+
<ContextMenuProvider isTriggerDisabled={isTriggerDisabled}>
116118
<div
117119
className="relative flex-1 overflow-hidden rounded-r-lg border border-l-0"
118120
onDragOver={onDragOver}

0 commit comments

Comments
 (0)