Ability to close tabs with mouse middle click when close ("x") button is hidden (#3335) #20041

Closed
opened 2026-01-31 07:01:32 +00:00 by claunia · 9 comments
Owner

Originally created by @thenger on GitHub (Jun 6, 2023).

Description of the new feature/enhancement

Problem

Can't close tab using mouse middle click.

Consequence

This is a consequence of #3335 (hide close button (x) on tabs).

Possible workaround not perfect

I think keyboard shortcuts are not a solution when you browse tabs with mouse.

Feature result

When close button is hidden, user can close tab using the mouse middle click

Originally created by @thenger on GitHub (Jun 6, 2023). # Description of the new feature/enhancement ## Problem Can't close tab using mouse middle click. ## Consequence This is a consequence of #3335 (hide close button (x) on tabs). ## Possible workaround not perfect I think keyboard shortcuts are not a solution when you browse tabs with mouse. # Feature result When close button is hidden, user can close tab using the mouse middle click
Author
Owner

@j4james commented on GitHub (Jun 6, 2023):

I think something like this will ultimately be supported via configurable mouse bindings (see issue #1553). The idea being that you could choose what action you want a mouse button to perform in a particular context. In this case, you'd bind the middle mouse button to the Close Tab action when the mouse is located over a tab.

This operation is interesting, though, because you would assumedly want to close the tab that you're hovering hover, rather than the active tab. That's something that'll need to be accounted for in the binding format which I don't think has been considered before.

@j4james commented on GitHub (Jun 6, 2023): I think something like this will ultimately be supported via configurable mouse bindings (see issue #1553). The idea being that you could choose what action you want a mouse button to perform in a particular context. In this case, you'd bind the middle mouse button to the _Close Tab_ action when the mouse is located over a tab. This operation is interesting, though, because you would assumedly want to close the tab that you're hovering hover, rather than the active tab. That's something that'll need to be accounted for in the binding format which I don't think has been considered before.
Author
Owner

@lhecker commented on GitHub (Jun 6, 2023):

I agree about the configurability aspect, but I personally feel like middle click should by default close the hovered tab even if the X button is hidden. Or was that done intentionally?

@lhecker commented on GitHub (Jun 6, 2023): I agree about the configurability aspect, but I personally feel like middle click should by default close the hovered tab even if the X button is hidden. Or was that done intentionally?
Author
Owner

@DHowett commented on GitHub (Jun 6, 2023):

It's, ah, an implementation detail. The only way to suppress the X button was to mark the tab as non-closeable. We should fix it more comprehensively... 😝

@DHowett commented on GitHub (Jun 6, 2023): It's, ah, an implementation detail. The only way to suppress the X button was to mark the tab as non-closeable. We should fix it more comprehensively... 😝
Author
Owner

@j4james commented on GitHub (Jun 6, 2023):

Oh I didn't realise this was already the default behavior when the close button is visible, since I don't have a middle mouse button. If that's the case, I agree it should continue to work when the button is hidden. However, I still think it's worth referencing this issue in #1553 if we eventually plan to support this as a configurable binding, because it is a bit different from other actions.

@j4james commented on GitHub (Jun 6, 2023): Oh I didn't realise this was already the default behavior when the close button is visible, since I don't have a middle mouse button. If that's the case, I agree it should continue to work when the button is hidden. However, I still think it's worth referencing this issue in #1553 if we eventually plan to support this as a configurable binding, because it is a bit different from other actions.
Author
Owner

@rifat01mahmud commented on GitHub (Jun 19, 2023):

To enable the ability to close tabs with a middle click when the close ("x") button is hidden in Microsoft Terminal, you can modify the Terminal settings by adding a custom key binding. Here's an example of how you can achieve this:

  1. Open Microsoft Terminal and click on the downward-facing arrow located at the top-right corner of the window. This will open the drop-down menu.

  2. Select "Settings" from the drop-down menu. This will open the settings file in your default text editor.

  3. In the settings file, locate the "actions" section. This section contains an array of key bindings and actions.

  4. Add the following code snippet to the "actions" array:

{
  "command": "closeTab",
  "keys": [
    "middleButton"
  ]
}

This code snippet defines a new key binding for the middle button, which will trigger the "closeTab" action.

  1. Save the settings file and close the text editor.

  2. Restart Microsoft Terminal for the changes to take effect.

After performing these steps, you should be able to close tabs by middle-clicking on them, even when the close ("x") button is hidden in Microsoft Terminal.

@rifat01mahmud commented on GitHub (Jun 19, 2023): To enable the ability to close tabs with a middle click when the close ("x") button is hidden in Microsoft Terminal, you can modify the Terminal settings by adding a custom key binding. Here's an example of how you can achieve this: 1. Open Microsoft Terminal and click on the downward-facing arrow located at the top-right corner of the window. This will open the drop-down menu. 2. Select "Settings" from the drop-down menu. This will open the settings file in your default text editor. 3. In the settings file, locate the `"actions"` section. This section contains an array of key bindings and actions. 4. Add the following code snippet to the `"actions"` array: ```json { "command": "closeTab", "keys": [ "middleButton" ] } ``` This code snippet defines a new key binding for the middle button, which will trigger the `"closeTab"` action. 5. Save the settings file and close the text editor. 6. Restart Microsoft Terminal for the changes to take effect. After performing these steps, you should be able to close tabs by middle-clicking on them, even when the close ("x") button is hidden in Microsoft Terminal.
Author
Owner

@thenger commented on GitHub (Jun 21, 2023):

This doesn't work for me.
Well at least it closes the "settings" tab with the middle click.

What version are you testing this in ?

edit :
my version:

Windows Terminal
Version: 1.17.11461.0

on w11

@thenger commented on GitHub (Jun 21, 2023): This doesn't work for me. Well at least it closes the "settings" tab with the middle click. What version are you testing this in ? edit : my version: Windows Terminal Version: 1.17.11461.0 on w11
Author
Owner

@thenger commented on GitHub (Aug 9, 2024):

It was in milestone 1.19
but it looks like it got lost ?

@thenger commented on GitHub (Aug 9, 2024): It was in milestone 1.19 but it looks like it got lost ?
Author
Owner

@Vampire commented on GitHub (Aug 9, 2024):

On 2023-06-07 it was added to "Terminal v1.19".
On 2023-08-17 it was removed from "Terminal v1.19" and added to "Backlog" and label "Help Wanted" added.
So, ...

@Vampire commented on GitHub (Aug 9, 2024): On 2023-06-07 it was added to "Terminal v1.19". On 2023-08-17 it was removed from "Terminal v1.19" and added to "Backlog" and label "Help Wanted" added. So, ...
Author
Owner

@carlos-zamora commented on GitHub (Dec 3, 2025):

Verified that this works in v1.25.3281.0 (Canary), v1.24.2812 (Preview), and v1.23.12811 (Stable). Not sure when exactly it as fixed, but definitely a while back now, it seems. Closing.

@carlos-zamora commented on GitHub (Dec 3, 2025): Verified that this works in v1.25.3281.0 (Canary), v1.24.2812 (Preview), and v1.23.12811 (Stable). Not sure when exactly it as fixed, but definitely a while back now, it seems. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#20041