Merge pull request #779 from frixxx/feature/close-tabs-with-mouse

Make Tabs closable by mouseclick. Closes #778
This commit is contained in:
Anoop M D 2023-10-25 22:40:33 +05:30 committed by GitHub
commit 7fbd8f0a8a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,7 +4,7 @@ import filter from 'lodash/filter';
import classnames from 'classnames';
import { IconChevronRight, IconChevronLeft } from '@tabler/icons';
import { useSelector, useDispatch } from 'react-redux';
import { focusTab } from 'providers/ReduxStore/slices/tabs';
import { closeTabs, focusTab } from 'providers/ReduxStore/slices/tabs';
import NewRequest from 'components/Sidebar/NewRequest';
import CollectionToolBar from './CollectionToolBar';
import RequestTab from './RequestTab';
@ -35,6 +35,14 @@ const RequestTabs = () => {
);
};
const handleCloseClick = (tab) => {
dispatch(
closeTabs({
tabUids: [tab.uid]
})
);
};
const createNewTab = () => setNewRequestModalOpen(true);
if (!activeTabUid) {
@ -110,6 +118,7 @@ const RequestTabs = () => {
className={getTabClassname(tab, index)}
role="tab"
onClick={() => handleClick(tab)}
onAuxClick={() => handleCloseClick(tab)}
>
<RequestTab key={tab.uid} tab={tab} collection={activeCollection} />
</li>