diff --git a/apps/ui/src/components/layout/project-switcher/components/project-context-menu.tsx b/apps/ui/src/components/layout/project-switcher/components/project-context-menu.tsx index 39a7b652..e0bb1af4 100644 --- a/apps/ui/src/components/layout/project-switcher/components/project-context-menu.tsx +++ b/apps/ui/src/components/layout/project-switcher/components/project-context-menu.tsx @@ -1,6 +1,7 @@ import { useEffect, useRef, useState, memo } from 'react'; import type { LucideIcon } from 'lucide-react'; import { Edit2, Trash2, Palette, ChevronRight, Moon, Sun, Monitor } from 'lucide-react'; +import { toast } from 'sonner'; import { cn } from '@/lib/utils'; import { type ThemeMode, useAppStore } from '@/store/app-store'; import { ConfirmDialog } from '@/components/ui/confirm-dialog'; @@ -129,14 +130,20 @@ export function ProjectContextMenu({ const { handlePreviewEnter, handlePreviewLeave } = useThemePreview({ setPreviewTheme }); useEffect(() => { - const handleClickOutside = (event: MouseEvent) => { - if (menuRef.current && !menuRef.current.contains(event.target as Node)) { + const handleClickOutside = (event: globalThis.MouseEvent) => { + // Don't close if a confirmation dialog is open (dialog is in a portal) + if (showRemoveDialog) return; + + if (menuRef.current && !menuRef.current.contains(event.target as globalThis.Node)) { setPreviewTheme(null); onClose(); } }; - const handleEscape = (event: KeyboardEvent) => { + const handleEscape = (event: globalThis.KeyboardEvent) => { + // Don't close if a confirmation dialog is open (let the dialog handle escape) + if (showRemoveDialog) return; + if (event.key === 'Escape') { setPreviewTheme(null); onClose(); @@ -150,7 +157,7 @@ export function ProjectContextMenu({ document.removeEventListener('mousedown', handleClickOutside); document.removeEventListener('keydown', handleEscape); }; - }, [onClose, setPreviewTheme]); + }, [onClose, setPreviewTheme, showRemoveDialog]); const handleEdit = () => { onEdit(project); @@ -173,149 +180,155 @@ export function ProjectContextMenu({ const handleConfirmRemove = () => { moveProjectToTrash(project.id); + toast.success('Project removed', { + description: `${project.name} has been removed from your projects list`, + }); onClose(); }; return ( <> -
-
- - - {/* Theme Submenu Trigger */} -
setShowThemeSubmenu(true)} - onMouseLeave={() => { - setShowThemeSubmenu(false); - setPreviewTheme(null); - }} - > + {/* Hide context menu when confirm dialog is open */} + {!showRemoveDialog && ( +
+
- {/* Theme Submenu */} - {showThemeSubmenu && ( -
setShowThemeSubmenu(true)} + onMouseLeave={() => { + setShowThemeSubmenu(false); + setPreviewTheme(null); + }} + > + + + Project Theme + {project.theme && ( + + {project.theme} + + )} + + -
+ {/* Theme Submenu */} + {showThemeSubmenu && ( +
+
+ {/* Use Global Option */} + - {/* Two Column Layout - Using reusable ThemeColumn component */} -
- - +
+ + {/* Two Column Layout - Using reusable ThemeColumn component */} +
+ + +
-
- )} -
+ )} +
- + +
-
+ )}