diff --git a/frontend/app/tab/tab.tsx b/frontend/app/tab/tab.tsx index 513494b01..aa3eccebc 100644 --- a/frontend/app/tab/tab.tsx +++ b/frontend/app/tab/tab.tsx @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { Button } from "@/element/button"; +import { ContextMenuModel } from "@/store/contextmenu"; import * as services from "@/store/services"; import * as WOS from "@/store/wos"; import { clsx } from "clsx"; @@ -16,7 +17,7 @@ interface TabProps { isBeforeActive: boolean; isDragging: boolean; onSelect: () => void; - onClose: (event: React.MouseEvent) => void; + onClose: (event: React.MouseEvent | null) => void; onDragStart: (event: React.MouseEvent) => void; onLoaded: () => void; } @@ -106,12 +107,20 @@ const Tab = forwardRef( event.stopPropagation(); }; + function handleContextMenu(e: React.MouseEvent) { + e.preventDefault(); + let menu: ContextMenuItem[] = []; + menu.push({ label: "Close Tab", click: () => onClose(null) }); + ContextMenuModel.showContextMenu(menu, e); + } + return (
{isFirst &&
} diff --git a/frontend/app/tab/tabbar.tsx b/frontend/app/tab/tabbar.tsx index 17ff253ae..6d419ee69 100644 --- a/frontend/app/tab/tabbar.tsx +++ b/frontend/app/tab/tabbar.tsx @@ -447,8 +447,8 @@ const TabBar = ({ workspace }: TabBarProps) => { }, 30); }; - const handleCloseTab = (event: React.MouseEvent, tabId: string) => { - event.stopPropagation(); + const handleCloseTab = (event: React.MouseEvent | null, tabId: string) => { + event?.stopPropagation(); services.WindowService.CloseTab(tabId); deleteLayoutStateAtomForTab(tabId); };