Skip to content

Commit aa5d282

Browse files
committed
[#9699] Close tab on middle-click
Add onMouseDown handler to the tab close button that fires layoutDocker.close() when mouse button 1 (middle click) is pressed. preventDefault() stops the browser's auto-scroll cursor from appearing. This matches the standard UX in Chrome, Firefox, and VS Code where middle-click on a tab closes it.
1 parent 2576548 commit aa5d282

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export function TabTitle({id, closable, defaultInternal}) {
6767
<span style={{textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap'}} data-visible={layoutDocker.isTabVisible(id)}>{attrs.title}</span>
6868
{closable && <PgIconButton title={gettext('Close')} icon={<CloseIcon style={{height: '0.7em'}} />} size="xs" noBorder onClick={()=>{
6969
layoutDocker.close(id);
70+
}} onMouseDown={(e)=>{
71+
if(e.button === 1) { e.preventDefault(); layoutDocker.close(id); }
7072
}} style={{margin: '-1px -10px -1px 0'}} />}
7173
</Box>
7274
);

0 commit comments

Comments
 (0)