diff --git a/src/components/cards/data-table.tsx b/src/components/cards/data-table.tsx index b82e5dd..bf5f1af 100644 --- a/src/components/cards/data-table.tsx +++ b/src/components/cards/data-table.tsx @@ -28,13 +28,7 @@ import { TableHeader, TableRow, } from "@/components/ui/table"; -import { - DropdownMenu, - DropdownMenuCheckboxItem, - DropdownMenuContent, - DropdownMenuLabel, - DropdownMenuSeparator, -} from "@/components/ui/dropdown-menu"; +import { Checkbox } from "@/components/ui/checkbox"; import { Badge } from "@/components/ui/badge"; import { cn } from "@/lib/utils"; import type { ResponseCard } from "./columns"; @@ -120,6 +114,7 @@ export function DataTable({ x: number; y: number; } | null>(null); + const contextMenuRef = React.useRef(null); const table = useReactTable({ data, @@ -185,7 +180,15 @@ export function DataTable({ React.useEffect(() => { if (!contextMenu) return; - const close = () => setContextMenu(null); + const close = (e: MouseEvent) => { + if ( + contextMenuRef.current && + contextMenuRef.current.contains(e.target as Node) + ) { + return; + } + setContextMenu(null); + }; window.addEventListener("click", close); window.addEventListener("contextmenu", close); return () => { @@ -463,35 +466,30 @@ export function DataTable({ {/* Right-click column visibility context menu */} {contextMenu && ( - { - if (!open) setContextMenu(null); - }} +
- - Toggle Columns - - {TOGGLEABLE_COLUMNS.map((col) => ( - + Toggle Columns +
+
+ {TOGGLEABLE_COLUMNS.map((col) => ( + + ))} +
)} );