Don't yeet focus to the control when the tab renamer is opened (#10114)

This is a hotfix to #10048. When the tab renamer is opened, we need to make sure to not immediately steal focus from it.

* [x] closes #10112
* [x] I work here
* [x] tested manually
This commit is contained in:
Mike Griese 2021-05-18 13:48:57 -05:00 committed by GitHub
parent e3d673ecd4
commit 24f80bd9ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 1 deletions

View file

@ -55,6 +55,18 @@ namespace winrt::TerminalApp::implementation
});
}
// Method Description:
// - Returns true if we're in the middle of a tab rename. This is used to
// mitigate GH#10112.
// Arguments:
// - <none>
// Return Value:
// - true if the renamer is open.
bool TabHeaderControl::InRename()
{
return Windows::UI::Xaml::Visibility::Visible == HeaderRenamerTextBox().Visibility();
}
// Method Description:
// - Show the tab rename box for the user to rename the tab title
// - We automatically use the previous title as the initial text of the box

View file

@ -18,6 +18,8 @@ namespace winrt::TerminalApp::implementation
void RenameBoxLostFocusHandler(winrt::Windows::Foundation::IInspectable const& sender,
winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
bool InRename();
WINRT_CALLBACK(TitleChangeRequested, TerminalApp::TitleChangeRequestedArgs);
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);

View file

@ -14,6 +14,8 @@ namespace TerminalApp
TabHeaderControl();
void BeginRename();
Boolean InRename { get; };
TerminalTabStatus TabStatus { get; set; };
event TitleChangeRequestedArgs TitleChangeRequested;

View file

@ -899,7 +899,13 @@ namespace winrt::TerminalApp::implementation
contextMenuFlyout.Closed([weakThis](auto&&, auto&&) {
if (auto tab{ weakThis.get() })
{
tab->_RequestFocusActiveControlHandlers();
// GH#10112 - if we're opening the tab renamer, don't
// immediately toss focus to the control. We don't want to steal
// focus from the tab renamer.
if (!tab->_headerControl.InRename())
{
tab->_RequestFocusActiveControlHandlers();
}
}
});
_AppendCloseMenuItems(contextMenuFlyout);