The PowerItem.jsx now supports a middle click

This commit is contained in:
Mathias Wagner 2023-06-02 20:37:00 +02:00
parent b9d7062eba
commit b482e1e8b7
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

@ -6,8 +6,16 @@ export const PowerItem = ({icon, name, path}) => {
const location = useLocation();
const navigate = useNavigate();
const mouseDown = (event) => {
if (event.button === 1) {
event.preventDefault();
window.open(window.location.origin + path, "_blank");
}
}
return (
<div className={"power-item" + (location.pathname === path ? " power-item-active" : "")} onClick={() => navigate(path)}>
<div className={"power-item" + (location.pathname === path ? " power-item-active" : "")}
onMouseDown={mouseDown} onClick={() => navigate(path)}>
<FontAwesomeIcon icon={icon}/>
<h2>{name}</h2>
</div>