Skip to content

Commit

Permalink
Add a keyboard shortcut handler to the TabRowControl (#12260)
Browse files Browse the repository at this point in the history
This makes the scenario mentioned in #8480 work. It's maybe not as holistic a solution as we'd like, but it definitely works.

Tested both with Narrator, and using the TabView scroll handles to get tab focus into the tab row manually

* [x] Closing the _active_ tab with <kbd>Ctrl+Shift+w</kbd> works (not the `TabViewItem` that has focus, but that's how Edgium works so that seems fine)
* [x] Opening a tab with <kbd>Ctrl+Shift+t</kbd> works
* [x] Opening the cmdpal with <kbd>Ctrl+Shift+p</kbd> works
* [x] Will take care of #8480 once we get the a11y team to validate
* [x] I work here


#### Notes:

None of

```xaml
PreviewKeyDown="_KeyDownHandler"
KeyDown="_KeyDownHandler"
KeyUp="_KeyDownHandler"
```

On the TerminalPage directly seem to fire when the focus is in the `TabViewItem` or the New Tab flyout. But they fire just fine when focus is in the `TermControl`. Interesting, because you'd think that the `TermControl` would have already handled the key...
  • Loading branch information
zadjii-msft committed Jan 26, 2022
1 parent d89c241 commit 6f69487
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/TabBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,5 @@ namespace winrt::TerminalApp::implementation
}
});
}

}
6 changes: 6 additions & 0 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,12 @@ namespace winrt::TerminalApp::implementation

// Method Description:
// - Called when the users pressed keyBindings while CommandPalette is open.
// - As of GH#8480, this is also bound to the TabRowControl's KeyUp event.
// That should only fire when focus is in the tab row, which is hard to
// do. Notably, that's possible:
// - When you have enough tabs to make the little scroll arrows appear,
// click one, then hit tab
// - When Narrator is in Scan mode (which is the a11y bug we're fixing here)
// - This method is effectively an extract of TermControl::_KeyHandler and TermControl::_TryHandleKeyBinding.
// Arguments:
// - e: the KeyRoutedEventArgs containing info about the keystroke.
Expand Down
3 changes: 2 additions & 1 deletion src/cascadia/TerminalApp/TerminalPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
</Grid.RowDefinitions>

<local:TabRowControl x:Name="TabRow"
Grid.Row="0" />
Grid.Row="0"
KeyUp="_KeyDownHandler" />

<StackPanel Grid.Row="1">
<mux:InfoBar x:Name="KeyboardServiceWarningInfoBar"
Expand Down

0 comments on commit 6f69487

Please sign in to comment.