From 6b60b339d62fcdcd683efd15e7ae5352504b72ab Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 18 Nov 2025 00:26:56 +0100 Subject: [PATCH] update: show tab menu on right click --- .../src/components/SheetTabBar/SheetTab.tsx | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/webapp/IronCalc/src/components/SheetTabBar/SheetTab.tsx b/webapp/IronCalc/src/components/SheetTabBar/SheetTab.tsx index ffcdbce..69b019d 100644 --- a/webapp/IronCalc/src/components/SheetTabBar/SheetTab.tsx +++ b/webapp/IronCalc/src/components/SheetTabBar/SheetTab.tsx @@ -31,17 +31,23 @@ interface SheetTabProps { function SheetTab(props: SheetTabProps) { const { name, color, selected, workbookState, onSelected } = props; - const [anchorEl, setAnchorEl] = useState(null); + const [anchorEl, setAnchorEl] = useState(null); const [colorPickerOpen, setColorPickerOpen] = useState(false); const colorButton = useRef(null); const open = Boolean(anchorEl); const { t } = useTranslation(); - const handleOpen = (event: React.MouseEvent) => { + const handleOpen = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget); }; const handleClose = () => { setAnchorEl(null); }; + const handleContextMenu = (event: React.MouseEvent) => { + event.preventDefault(); + event.stopPropagation(); + onSelected(); + setAnchorEl(event.currentTarget); + }; const [renameDialogOpen, setRenameDialogOpen] = useState(false); const handleCloseRenameDialog = () => { setRenameDialogOpen(false); @@ -70,6 +76,7 @@ function SheetTab(props: SheetTabProps) { event.stopPropagation(); event.preventDefault(); }} + onContextMenu={handleContextMenu} onPointerDown={(event: React.PointerEvent) => { // If it is in browse mode stop he event const cell = workbookState.getEditingCell(); @@ -81,7 +88,7 @@ function SheetTab(props: SheetTabProps) { ref={colorButton} > {name} - + @@ -221,26 +228,25 @@ const TabWrapper = styled("div")<{ $color: string; $selected: boolean }>` props.$selected ? `${theme.palette.grey[50]}80` : "transparent"}; `; -const StyledButton = styled(Button)` - width: 15px; - height: 24px; +const StyledButton = styled(Button)<{ $active?: boolean }>` + width: 16px; + height: 16px; min-width: 0px; padding: 0px; color: inherit; font-weight: inherit; + border-radius: 4px; + background-color: ${(props) => + props.$active ? `${theme.palette.grey[300]}` : "transparent"}; &:hover { - background-color: transparent; + background-color: ${theme.palette.grey[200]}; } &:active { - background-color: transparent; + background-color: ${theme.palette.grey[300]}; } svg { - width: 15px; - height: 15px; - transition: transform 0.2s; - } - &:hover svg { - transform: translateY(2px); + width: 14px; + height: 14px; } `;