Skip to content

Commit d6d0b2c

Browse files
committed
[#9699] Close tab on middle-click of tab title
1 parent aa5d282 commit d6d0b2c

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

  • web/pgadmin/static/js/helpers/Layout

web/pgadmin/static/js/helpers/Layout/index.jsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ export function TabTitle({id, closable, defaultInternal}) {
4545
layoutDocker.eventBus.fireEvent(LAYOUT_EVENTS.CONTEXT, e, id);
4646
}, []);
4747

48+
const onMouseDown = useCallback((e)=>{
49+
if(closable && e.button === 1) {
50+
e.preventDefault();
51+
layoutDocker.close(id);
52+
}
53+
}, [closable, id, layoutDocker]);
54+
4855
useEffect(()=>{
4956
const deregister = layoutDocker.eventBus.registerListener(LAYOUT_EVENTS.REFRESH_TITLE, (panelId)=>{
5057
if(panelId == id) {
@@ -62,13 +69,11 @@ export function TabTitle({id, closable, defaultInternal}) {
6269
}, []);
6370

6471
return (
65-
<Box display="flex" alignItems="center" title={attrs.tooltip} onContextMenu={onContextMenu} width="100%">
72+
<Box display="flex" alignItems="center" title={attrs.tooltip} onContextMenu={onContextMenu} onMouseDown={onMouseDown} width="100%">
6673
{attrs.icon && <span className={`dock-tab-icon ${attrs.icon}`}></span>}
6774
<span style={{textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap'}} data-visible={layoutDocker.isTabVisible(id)}>{attrs.title}</span>
6875
{closable && <PgIconButton title={gettext('Close')} icon={<CloseIcon style={{height: '0.7em'}} />} size="xs" noBorder onClick={()=>{
6976
layoutDocker.close(id);
70-
}} onMouseDown={(e)=>{
71-
if(e.button === 1) { e.preventDefault(); layoutDocker.close(id); }
7277
}} style={{margin: '-1px -10px -1px 0'}} />}
7378
</Box>
7479
);

0 commit comments

Comments
 (0)