Allow middle button click to close a tab

Fixes #1993
This commit is contained in:
Martynas Bagdonas 2021-08-24 12:18:40 +03:00
parent 3ca236f057
commit b6d562b0cb

View file

@ -55,6 +55,12 @@ const TabBar = forwardRef(function (props, ref) {
event.stopPropagation();
}
function handleTabClick(event, id) {
if (event.button === 1) {
props.onTabClose(id);
}
}
function handleTabBarMouseMove(event) {
if (!draggingID.current || mouseMoveWaitUntil.current > Date.now()) {
return;
@ -121,6 +127,7 @@ const TabBar = forwardRef(function (props, ref) {
className={cx('tab', { selected })}
onMouseMove={() => handleTabMouseMove(title)}
onMouseDown={(event) => handleTabMouseDown(event, id, index)}
onClick={(event) => handleTabClick(event, id)}
>
<div className="tab-name">{title}</div>
<div