Skip to content

fix: close tabs on middle-click over close overlay#8379

Open
reussio wants to merge 1 commit into
usebruno:mainfrom
reussio:bugfix/tab-middle-click-close-overlay
Open

fix: close tabs on middle-click over close overlay#8379
reussio wants to merge 1 commit into
usebruno:mainfrom
reussio:bugfix/tab-middle-click-close-overlay

Conversation

@reussio

@reussio reussio commented Jun 26, 2026

Copy link
Copy Markdown

Description

The tab close affordance uses a wider hover overlay than the visible icon. That overlay intercepted middle-click mouseup events before they reach the tab label, so middle-click close sotpped working on the right side of the tab.

This fixes #8378

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable. (in the issue)
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Summary by CodeRabbit

  • Bug Fixes
    • Improved middle-click behavior on request tab close buttons by preventing unintended browser autoscroll.
    • Made middle-button interactions more reliable by stopping default behavior and ensuring the close action still fires when available.

The tab close affordance uses a wider hover overlay than the visible icon. That overlay intercepted middle-click mouseup events before they reach the tab label, so middle-click close sotpped working on the right side of the tab.
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

GradientCloseButton now intercepts middle-mouse down and up events, prevents the browser autoscroll behavior, stops propagation on mouse up, and invokes the optional click handler through the wrapper.

Changes

Middle-click close behavior

Layer / File(s) Summary
Middle-click handlers
packages/bruno-app/src/components/RequestTabs/RequestTab/GradientCloseButton/index.js
Adds handleMouseDown and handleMouseUp to manage middle-button interactions, including default prevention, propagation stopping, and optional onClick invocation.
Wrapper event wiring
packages/bruno-app/src/components/RequestTabs/RequestTab/GradientCloseButton/index.js
Wires the new handlers into StyledWrapper through onMouseDown and onMouseUp props.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • usebruno/bruno#7443: Similar middle-click tab-close event handling changes in the tab close UI.

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

A tiny click in silver light,
Now closes tabs just right tonight.
The middle wheel no longer roams,
It finds its path and heads back home.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main fix: restoring middle-click tab closing near the close overlay.
Linked Issues check ✅ Passed The change directly addresses #8378 by handling middle-button events on the close overlay so tabs close consistently.
Out of Scope Changes check ✅ Passed The reported change is scoped to middle-click close handling on the tab close affordance, with no unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/bruno-app/src/components/RequestTabs/RequestTab/GradientCloseButton/index.js (1)

14-18: 🎯 Functional Correctness | 🔵 Trivial

Confirm the handleCloseClick implementation remains agnostic to event type.

The upstream handlers (handleCloseClick in RequestTab/index.js, ExampleTab/index.js, etc.) correctly treat the received event as a trigger token rather than inspecting e.type or e.button. This makes the current implementation of forwarding the mouseup event safe.

Ensure no future logic inside handleCloseClick or its callees branches on e.type === 'click'. The function should rely solely on the side effect (closing the tab) rather than the source event type.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/bruno-app/src/components/RequestTabs/RequestTab/GradientCloseButton/index.js`
around lines 14 - 18, The close-button event flow should stay event-agnostic:
`GradientCloseButton.handleMouseUp` forwards a `mouseup` event into `onClick`,
and the upstream `handleCloseClick` handlers in `RequestTab/index.js`,
`ExampleTab/index.js`, and similar should treat that event only as a trigger to
close, not inspect `e.type` or `e.button`. Review `handleCloseClick` and any
callees to remove or avoid branches based on the event source, keeping the
behavior driven solely by the close action.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@packages/bruno-app/src/components/RequestTabs/RequestTab/GradientCloseButton/index.js`:
- Around line 23-27: The GradientCloseButton overlay behavior needs regression
coverage for middle-click on the close affordance area. Add a test around the
GradientCloseButton component that exercises the close overlay via middle mouse
button while the pointer is over the overlay and verifies the tab still closes;
reference the StyledWrapper handlers and handleMouseDown/handleMouseUp path so
the test stays aligned if the implementation moves.

---

Nitpick comments:
In
`@packages/bruno-app/src/components/RequestTabs/RequestTab/GradientCloseButton/index.js`:
- Around line 14-18: The close-button event flow should stay event-agnostic:
`GradientCloseButton.handleMouseUp` forwards a `mouseup` event into `onClick`,
and the upstream `handleCloseClick` handlers in `RequestTab/index.js`,
`ExampleTab/index.js`, and similar should treat that event only as a trigger to
close, not inspect `e.type` or `e.button`. Review `handleCloseClick` and any
callees to remove or avoid branches based on the event source, keeping the
behavior driven solely by the close action.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 70737098-b8a6-41ce-bbd2-0de146966165

📥 Commits

Reviewing files that changed from the base of the PR and between d6e17e1 and cf93aae.

📒 Files selected for processing (1)
  • packages/bruno-app/src/components/RequestTabs/RequestTab/GradientCloseButton/index.js

Comment on lines +23 to +27
<StyledWrapper
className={`close-gradient ${hasChanges ? 'has-changes' : ''}`}
onMouseDown={handleMouseDown}
onMouseUp={handleMouseUp}
>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a regression test for middle-click over the close overlay.

This is a user-visible behavior fix, so it needs coverage proving middle-click still closes when the pointer is over the overlay area near the close affordance. As per coding guidelines, "Add tests for any new functionality or meaningful changes. If code is added, removed, or significantly modified, corresponding tests should be updated or created."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/bruno-app/src/components/RequestTabs/RequestTab/GradientCloseButton/index.js`
around lines 23 - 27, The GradientCloseButton overlay behavior needs regression
coverage for middle-click on the close affordance area. Add a test around the
GradientCloseButton component that exercises the close overlay via middle mouse
button while the pointer is over the overlay and verifies the tab still closes;
reference the StyledWrapper handlers and handleMouseDown/handleMouseUp path so
the test stays aligned if the implementation moves.

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Middle-click does not close tab near close icon hit area

1 participant