Close tab shortcut (Ctrl+F4) doesn't work if window focus is not on title bar #11805

Closed
opened 2026-01-31 02:57:57 +00:00 by claunia · 16 comments
Owner

Originally created by @ThomsonTan on GitHub (Dec 14, 2020).

Environment

Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd]
10.0.19042.685
Windows Terminal version (if applicable):
Latest preview.

Any other software?

Steps to reproduce

  1. Click + in the title bar to create a new tab in Windows Terminal.
  2. Press Ctrl+F4 to close the tab.

Expected behavior

The newly created tab is closed after Ctrl+F4.

Actual behavior

Nothing changed and the new tab still exists.

Seems Ctrl+F4 to close tab window only works if the tab/title bar has Window focus. For example, it works if I click tab title before pressing Ctrl+F4.

Originally created by @ThomsonTan on GitHub (Dec 14, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd] 10.0.19042.685 Windows Terminal version (if applicable): Latest preview. Any other software? ``` # Steps to reproduce 1. Click `+` in the title bar to create a new tab in Windows Terminal. 2. Press Ctrl+F4 to close the tab. <!-- A description of how to trigger this bug. --> # Expected behavior The newly created tab is closed after Ctrl+F4. <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> # Actual behavior Nothing changed and the new tab still exists. <!-- What's actually happening? --> Seems Ctrl+F4 to close tab window only works if the tab/title bar has Window focus. For example, it works if I click tab title before pressing Ctrl+F4.
Author
Owner

@DHowett commented on GitHub (Dec 14, 2020):

So, this is a weird thing. That binding's not supposed to work unless you go into your settings and explicitly bind it yourself. That it does work anywhere without it being bound explicitly is the bug I'd rather fix. 😄

@DHowett commented on GitHub (Dec 14, 2020): So, this is a weird thing. That binding's not supposed to work unless you go into your settings and explicitly bind it yourself. That it _does_ work anywhere without it being bound explicitly is the bug I'd rather fix. :smile:
Author
Owner

@zadjii-msft commented on GitHub (Dec 15, 2020):

I wonder if XAML is providing the Ctrl+F4 keybinding themselves... Oh they are!

309c88f81c/dev/TabView/TabView.cpp (L38-L43)

That's certainly interesting.

I'd say in general, if you want Ctrl+F4 to work to close a tab, I'd add a keybinding for it, since it's not bound by default. That would look something like

{ "keys": "ctrl+f4", "action": "closePane" }

(we use closePane because it's more versatile than closeTab - it will close the tab if you only have one open tab, and work to close the pane if you have multiple panes)

@zadjii-msft commented on GitHub (Dec 15, 2020): I wonder if XAML is providing the <kbd>Ctrl+F4</kbd> keybinding themselves... Oh they are! https://github.com/microsoft/microsoft-ui-xaml/blob/309c88f81cf23802d6406b452e4381fc9b4e9de1/dev/TabView/TabView.cpp#L38-L43 That's certainly interesting. I'd say in general, if you want <kbd>Ctrl+F4</kbd> to work to close a tab, I'd add a keybinding for it, since it's not bound by default. That would look something like ```json { "keys": "ctrl+f4", "action": "closePane" } ``` (we use `closePane` because it's more versatile than `closeTab` - it will close the tab if you only have one open tab, and work to close the pane if you have multiple panes)
Author
Owner

@Lindsay-Needs-Sleep commented on GitHub (Feb 4, 2021):

@zadjii-msft Thanks for the tip! Unfortunately it doesn't seem to work for me. :/

image

Like @ThomsonTan said, if I click on the tab head first, ctrl+f4 works.

Interestingly, ctrl+shift+w works like I wish ctrl+f4 did.

ctrl+tab also switches the tabs as expected (without having to click on the tab heads first. :S)

@Lindsay-Needs-Sleep commented on GitHub (Feb 4, 2021): @zadjii-msft Thanks for the tip! Unfortunately it doesn't seem to work for me. :/ ![image](https://user-images.githubusercontent.com/51773923/106827199-a3187e00-6645-11eb-84ff-9e35aecde584.png) Like @ThomsonTan said, if I click on the tab head first, ctrl+f4 works. Interestingly, ctrl+shift+w works like I wish ctrl+f4 did. ctrl+tab also switches the tabs as expected (without having to click on the tab heads first. :S)
Author
Owner

@zadjii-msft commented on GitHub (Feb 4, 2021):

I don't know what I was thinking closing this. Maybe because I was triaging at 5am?

Yea, we should unbind that from the TabView, so that Ctrl+F4 works in both the terminal content and in the tab view.

Now, how we remove that keybinding from the TabView is another question entirely.

@zadjii-msft commented on GitHub (Feb 4, 2021): I don't know what I was thinking closing this. Maybe because I was triaging at 5am? Yea, we should unbind that from the TabView, so that Ctrl+F4 works in both the terminal content _and_ in the tab view. Now, how we remove that keybinding from the TabView is another question entirely.
Author
Owner

@elouanKeryell-Even commented on GitHub (Mar 16, 2021):

Witnessing the same issue as ThomsonTan

@elouanKeryell-Even commented on GitHub (Mar 16, 2021): Witnessing the same issue as ThomsonTan
Author
Owner

@zadjii-msft commented on GitHub (Mar 16, 2021):

@elouanKeryell-Even If you'd like to "+1" this feature, the best way to do that is by hitting the 👍 button on this issue

image

That way, you avoid unnecessarily pinging everyone following this thread. Thanks!

@zadjii-msft commented on GitHub (Mar 16, 2021): @elouanKeryell-Even If you'd like to "+1" this feature, the best way to do that is by hitting the 👍 button on this issue ![image](https://user-images.githubusercontent.com/18356694/96140789-ef3c8880-0ec5-11eb-82e0-30ce4977b9a7.png) That way, you avoid unnecessarily pinging everyone following this thread. Thanks!
Author
Owner

@elouanKeryell-Even commented on GitHub (Mar 16, 2021):

As a work-around, is there a key bind to "focus tab bar"?

I looked it up in the docs but couldn't find something like this.

This way I could do:

  • key bind "focus tab bar"
  • key bind "close tab" (ctrl+f4)

... without using the mouse

@elouanKeryell-Even commented on GitHub (Mar 16, 2021): As a work-around, is there a key bind to "focus tab bar"? I looked it up in the docs but couldn't find something like this. This way I could do: - key bind "focus tab bar" - key bind "close tab" (ctrl+f4) ... without using the mouse
Author
Owner

@zadjii-msft commented on GitHub (Mar 16, 2021):

is there a key bind to "focus tab bar"?

Not currently, and outside the context of this bug, I'm not sure there's really a use case for that. I think it'd just be easier to solve the underlying bug then add the workaround 😉

@zadjii-msft commented on GitHub (Mar 16, 2021): > is there a key bind to "focus tab bar"? Not currently, and outside the context of this bug, I'm not sure there's really a use case for that. I think it'd just be easier to solve the underlying bug then add the workaround 😉
Author
Owner

@elouanKeryell-Even commented on GitHub (Mar 16, 2021):

@zadjii-msft ok thx, I think I'm gonna stick with the default WSL2 terminal for now, but I will check again Windows Terminal when this issue is solved :)

Have a good day

@elouanKeryell-Even commented on GitHub (Mar 16, 2021): @zadjii-msft ok thx, I think I'm gonna stick with the default WSL2 terminal for now, but I will check again Windows Terminal when this issue is solved :) Have a good day
Author
Owner

@DHowett commented on GitHub (Mar 16, 2021):

@elouanKeryell-Even If I may point out... the default WSL console host also does not support Ctrl+F4. What specifically about this key binding is holding you back?

Just to be clear: you can keybind ctrl+f4 to "closeTab", and you can use the nextTab/prevTab key bindings to navigate tabs without interacting with the tab bar.

What specific thing do you need to focus the tab bar for?

@DHowett commented on GitHub (Mar 16, 2021): @elouanKeryell-Even If I may point out... the default WSL console host _also does not support <kbd>Ctrl+F4</kbd>_. What specifically about this key binding is holding you back? Just to be clear: you can keybind ctrl+f4 to "`closeTab`", and you can use the `nextTab`/`prevTab` key bindings to navigate tabs without interacting with the tab bar. What specific thing do you need to focus the tab bar for?
Author
Owner

@zadjii-msft commented on GitHub (Mar 16, 2021):

HOLY GOSH.

The whole thesis of this bug is premised on a typo.

The keybinding should be

        { "keys": "ctrl+f4", "command": "closePane" },

command. Not action.

That works perfectly fine in the terminal today. That's what I get for triaging at 5am.

@zadjii-msft commented on GitHub (Mar 16, 2021): HOLY GOSH. The whole thesis of this bug is premised on a typo. The keybinding should be ```json { "keys": "ctrl+f4", "command": "closePane" }, ``` `command`. Not `action`. That works perfectly fine in the terminal today. That's what I get for triaging at 5am.
Author
Owner

@SGM3 commented on GitHub (Apr 19, 2021):

Using Version: 1.7.1033.0

Not sure whether it was intended or not but there is a tooltip over the the tab's [X] button that say closing is Ctrl + F4, but on a fresh install of the above, its not there.

Was able to add the command in the JSON file and then it works perfectly.

@SGM3 commented on GitHub (Apr 19, 2021): Using Version: 1.7.1033.0 Not sure whether it was intended or not but there is a tooltip over the the tab's [X] button that say closing is Ctrl + F4, but on a fresh install of the above, its not there. Was able to add the command in the JSON file and then it works perfectly.
Author
Owner

@basic-settings commented on GitHub (Sep 20, 2021):

Not sure whether it was intended or not but there is a tooltip over the the tab's [X] button that say closing is Ctrl + F4, but on a fresh install of the above, its not there.

Can confirm the above, the tooltip says it on a fresh install but it's not functional without the focus. Adding the "closeTab" binding works.

@basic-settings commented on GitHub (Sep 20, 2021): > Not sure whether it was intended or not but there is a tooltip over the the tab's [X] button that say closing is Ctrl + F4, but on a fresh install of the above, its not there. Can confirm the above, the tooltip says it on a fresh install but it's not functional without the focus. Adding the "closeTab" binding works.
Author
Owner

@lackovic commented on GitHub (Jan 18, 2023):

there is a tooltip over the the tab's [X] button that say closing is Ctrl + F4, but on a fresh install of the above, its not there.

I confirm that this is still there. Should the tooltip not be displayed if the relative configuration does not exist?

@lackovic commented on GitHub (Jan 18, 2023): > there is a tooltip over the the tab's [X] button that say closing is Ctrl + F4, but on a fresh install of the above, its not there. I confirm that this is still there. Should the tooltip not be displayed if the relative configuration does not exist?
Author
Owner

@Gorschel commented on GitHub (Apr 20, 2023):

just fix the tool tip description for the "close Tab" [x] button to "CTRL+SHIFT+W" and this shouldnt be an issue any longer.
But please consoder sticking to standard hotkey conventions like switching through the tabs with CTRL+PGUP/DOWN

@Gorschel commented on GitHub (Apr 20, 2023): just fix the tool tip description for the "close Tab" [x] button to "CTRL+SHIFT+W" and this shouldnt be an issue any longer. But please consoder sticking to standard hotkey conventions like switching through the tabs with CTRL+PGUP/DOWN
Author
Owner

@zadjii-msft commented on GitHub (Apr 20, 2023):

@Gorschel As mentioned earlier in the thread, there's no way for us to override that text. It's being generated in code-behind in WInUI itself, and there's no way for us to replace that.

In general, Terminal tries to make sure to add shift to our default keybindings, because all sorts of commandline applications will also try to bind the non-shift versions, and we try to not step on their toes. It's a point of pain that we've experienced many times in the past. You're always free to rebind keybindings as you see fit!

@zadjii-msft commented on GitHub (Apr 20, 2023): @Gorschel As mentioned earlier in the thread, there's no way for us to override that text. It's being generated in code-behind in WInUI itself, and there's no way for us to replace that. In general, Terminal tries to make sure to add <kbd>shift</kbd> to our default keybindings, because all sorts of commandline applications will also try to bind the non-shift versions, and we try to not step on their toes. It's a point of pain that we've experienced _many_ times in the past. You're _always_ free to rebind keybindings as you see fit!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11805