Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ThomsonTan opened this issue Dec 14, 2020 · 16 comments
Closed
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Answered Related to questions that have been answered

Comments

@ThomsonTan
Copy link

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.

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Dec 14, 2020
@DHowett
Copy link
Member

DHowett commented 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. 😄

@zadjii-msft
Copy link
Member

I wonder if XAML is providing the Ctrl+F4 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 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 zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Issue-Question For questions or discussion Product-Terminal The new Windows Terminal. Resolution-Answered Related to questions that have been answered labels Dec 15, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Dec 15, 2020
@Lindsay-Needs-Sleep
Copy link

@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)

@zadjii-msft
Copy link
Member

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 zadjii-msft reopened this Feb 4, 2021
@zadjii-msft zadjii-msft added Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) and removed Issue-Question For questions or discussion Resolution-Answered Related to questions that have been answered labels Feb 4, 2021
@zadjii-msft zadjii-msft added this to the Terminal v2.0 milestone Feb 4, 2021
@DHowett DHowett removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Feb 17, 2021
@elouanKeryell-Even

This comment has been minimized.

@zadjii-msft

This comment has been minimized.

@elouanKeryell-Even
Copy link

elouanKeryell-Even commented 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

@zadjii-msft
Copy link
Member

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 zadjii-msft added the Help Wanted We encourage anyone to jump in on these. label Mar 16, 2021
@elouanKeryell-Even
Copy link

@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

@DHowett
Copy link
Member

DHowett commented 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?

@zadjii-msft
Copy link
Member

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.

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Mar 16, 2021
@zadjii-msft zadjii-msft removed this from the Terminal v2.0 milestone Mar 16, 2021
@zadjii-msft zadjii-msft added the Resolution-Answered Related to questions that have been answered label Mar 16, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Mar 16, 2021
@SGM3
Copy link

SGM3 commented 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.

@basic-settings
Copy link

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.

@lackovic
Copy link

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?

@Gorschel
Copy link

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

@zadjii-msft
Copy link
Member

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. Resolution-Answered Related to questions that have been answered
Projects
None yet
Development

No branches or pull requests

9 participants