Skip to content

Commit

Permalink
fix: middle button click to close - SpecialTab and RequestTabNotFound…
Browse files Browse the repository at this point in the history
… tab (#3044)
  • Loading branch information
Pragadesh-45 authored Sep 11, 2024
1 parent 087bab6 commit 98a7aa1
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions packages/bruno-app/src/components/RequestTabs/RequestTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi

const handleMouseUp = (e) => {
if (e.button === 1) {
e.stopPropagation();
e.preventDefault();
e.stopPropagation();

// Close the tab
dispatch(
closeTabs({
tabUids: [tab.uid]
Expand All @@ -68,7 +69,10 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi
const folder = folderUid ? findItemInCollection(collection, folderUid) : null;
if (['collection-settings', 'folder-settings', 'variables', 'collection-runner', 'security-settings'].includes(tab.type)) {
return (
<StyledWrapper className="flex items-center justify-between tab-container px-1">
<StyledWrapper
className="flex items-center justify-between tab-container px-1"
onMouseUp={handleMouseUp} // Add middle-click behavior here
>
{tab.type === 'folder-settings' ? (
<SpecialTab handleCloseClick={handleCloseClick} type={tab.type} tabName={folder?.name} />
) : (
Expand All @@ -82,7 +86,17 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi

if (!item) {
return (
<StyledWrapper className="flex items-center justify-between tab-container px-1">
<StyledWrapper
className="flex items-center justify-between tab-container px-1"
onMouseUp={(e) => {
if (e.button === 1) {
e.preventDefault();
e.stopPropagation();

dispatch(closeTabs({ tabUids: [tab.uid] }));
}
}}
>
<RequestTabNotFound handleCloseClick={handleCloseClick} />
</StyledWrapper>
);
Expand Down

0 comments on commit 98a7aa1

Please sign in to comment.