feat: add middle mouse button click to close tab (#1649)

* feat: add middle click button to close tab
* refactor: remove unused code
* fix: verify if is middle click before trigger close confirmation modal
This commit is contained in:
Gabriel
2024-02-27 15:28:01 -03:00
committed by GitHub
parent 96bcc7074a
commit 18e7301550

View File

@@ -28,6 +28,19 @@ const RequestTab = ({ tab, collection }) => {
);
};
const handleMouseUp = (e) => {
if (e.button === 1) {
e.stopPropagation();
e.preventDefault();
dispatch(
closeTabs({
tabUids: [tab.uid]
})
);
}
};
const getMethodColor = (method = '') => {
const theme = storedTheme === 'dark' ? darkTheme : lightTheme;
@@ -124,7 +137,18 @@ const RequestTab = ({ tab, collection }) => {
}}
/>
)}
<div className="flex items-baseline tab-label pl-2">
<div
className="flex items-baseline tab-label pl-2"
onMouseUp={(e) => {
if (!item.draft) return handleMouseUp(e);
if (e.button === 1) {
e.stopPropagation();
e.preventDefault();
setShowConfirmClose(true);
}
}}
>
<span className="tab-method uppercase" style={{ color: getMethodColor(method), fontSize: 12 }}>
{method}
</span>