diff --git a/interface/app/$libraryId/Layout/Sidebar/SidebarLayout/Link.tsx b/interface/app/$libraryId/Layout/Sidebar/SidebarLayout/Link.tsx index af0d38751a2a..b70a765b26a2 100644 --- a/interface/app/$libraryId/Layout/Sidebar/SidebarLayout/Link.tsx +++ b/interface/app/$libraryId/Layout/Sidebar/SidebarLayout/Link.tsx @@ -1,6 +1,6 @@ import { cva } from 'class-variance-authority'; import clsx from 'clsx'; -import { forwardRef, PropsWithChildren } from 'react'; +import { forwardRef, PropsWithChildren, useEffect } from 'react'; import { NavLink, NavLinkProps } from 'react-router-dom'; import { useOperatingSystem } from '~/hooks/useOperatingSystem'; import { usePlatform } from '~/util/Platform'; @@ -31,6 +31,17 @@ const Link = forwardRef< const os = useOperatingSystem(); const { platform } = usePlatform(); + //prevents middle click from opening new tab + useEffect(() => { + const handleClick = (e: MouseEvent) => { + if (e.button === 1) e.preventDefault(); + }; + document.addEventListener('auxclick', handleClick); + return () => { + document.removeEventListener('auxclick', handleClick); + }; + }, []); + return ( {