From 5275c56725f07f7f2d5b4e2628b942bca068b87d Mon Sep 17 00:00:00 2001 From: Vijay <74645268+vijaysingh2219@users.noreply.github.com> Date: Wed, 10 Apr 2024 22:26:18 +0530 Subject: [PATCH] Implement functionality to open URL in new tab on middle click Added handleClick function to check for middle mouse button (event.button === 1), opening the URL in a new tab using window.open. Improves user experience by offering an alternative method to open URLs without leaving the current page. --- src/components/player/base/BackLink.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/player/base/BackLink.tsx b/src/components/player/base/BackLink.tsx index a965751f..23bcb668 100644 --- a/src/components/player/base/BackLink.tsx +++ b/src/components/player/base/BackLink.tsx @@ -1,3 +1,4 @@ +import React from "react"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; @@ -7,11 +8,23 @@ export function BackLink(props: { url: string }) { const { t } = useTranslation(); const navigate = useNavigate(); + const handleClick = (event: React.MouseEvent) => { + event.preventDefault(); + // Check if center mouse button is clicked + if (event.button === 1) { + // Open the URL in a new tab + window.open(props.url, "_blank"); + } else { + // Navigate normally for other clicks + navigate(props.url); + } + }; return (