diff --git a/packages/ui/src/components/ui/sortable-tabs-strip.tsx b/packages/ui/src/components/ui/sortable-tabs-strip.tsx index 1ee67178..52201ade 100644 --- a/packages/ui/src/components/ui/sortable-tabs-strip.tsx +++ b/packages/ui/src/components/ui/sortable-tabs-strip.tsx @@ -377,10 +377,31 @@ export const SortableTabsStrip: React.FC = ({ ? 'flex-none basis-auto' : (isMobile ? 'flex-1 basis-0 min-w-0' : 'flex-1 basis-0 min-w-fit')) : 'min-w-0 flex-1 basis-0'; + const handleAuxClick = closable + ? (event: React.MouseEvent) => { + // Middle-click (button === 1) closes the tab. Matches browser tab behavior. + if (event.button !== 1) { + return; + } + event.preventDefault(); + event.stopPropagation(); + onClose?.(item.id); + } + : undefined; + const handleMouseDown = closable + ? (event: React.MouseEvent) => { + // Prevent the browser's middle-click autoscroll affordance. + if (event.button === 1) { + event.preventDefault(); + } + } + : undefined; return (
setTabRef(item.id, element)} + onAuxClick={handleAuxClick} + onMouseDown={handleMouseDown} className={cn( 'group flex h-full min-w-0 flex-nowrap items-center', (isScrollable || useIntrinsicPillSizing)