Skip to content

Close tab on middle-click (#9699)#9767

Open
pavanmanishd wants to merge 2 commits intopgadmin-org:masterfrom
pavanmanishd:fix/9699-middle-click-tab
Open

Close tab on middle-click (#9699)#9767
pavanmanishd wants to merge 2 commits intopgadmin-org:masterfrom
pavanmanishd:fix/9699-middle-click-tab

Conversation

@pavanmanishd
Copy link

@pavanmanishd pavanmanishd commented Mar 21, 2026

Closes #9699

Enable middle-click tab close behavior by handling mouse button 1 on the tab title and closing the tab when it is closable. preventDefault() is used to avoid browser auto-scroll on middle click.

Summary by CodeRabbit

  • New Features
    • Added support for closing closable tabs using the middle mouse button for improved tab navigation.

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.
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ba389b45-af1c-4a43-8025-f5ae6e6f8136

📥 Commits

Reviewing files that changed from the base of the PR and between 2576548 and d6d0b2c.

📒 Files selected for processing (1)
  • web/pgadmin/static/js/helpers/Layout/index.jsx

Walkthrough

This change adds middle-click functionality to close tabs in pgAdmin's layout interface. When a user middle-clicks a closable tab, the event is prevented and the tab is closed through the layout docker's close method.

Changes

Cohort / File(s) Summary
Tab Middle-Click Handler
web/pgadmin/static/js/helpers/Layout/index.jsx
Added onMouseDown event handler to TabTitle's Box component that detects middle mouse button clicks (e.button === 1) on closable tabs, prevents default behavior, and closes the tab via layoutDocker.close(id).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding middle-click functionality to close tabs, which is the primary objective of this pull request.
Linked Issues check ✅ Passed The pull request implements the core requirement from issue #9699 by adding an onMouseDown handler that closes tabs on middle-click, matching browser conventions.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing middle-click tab closing functionality; no unrelated modifications are present in the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pavanmanishd pavanmanishd marked this pull request as ready for review March 22, 2026 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Middle clicking tab should close it

1 participant