Skip to content

Commit a2ab200

Browse files
zadjii-msftDHowett
authored andcommitted
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 (cherry picked from commit 24f80bd)
1 parent 90e78ec commit a2ab200

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/cascadia/TerminalApp/TabHeaderControl.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ namespace winrt::TerminalApp::implementation
5555
});
5656
}
5757

58+
// Method Description:
59+
// - Returns true if we're in the middle of a tab rename. This is used to
60+
// mitigate GH#10112.
61+
// Arguments:
62+
// - <none>
63+
// Return Value:
64+
// - true if the renamer is open.
65+
bool TabHeaderControl::InRename()
66+
{
67+
return Windows::UI::Xaml::Visibility::Visible == HeaderRenamerTextBox().Visibility();
68+
}
69+
5870
// Method Description:
5971
// - Show the tab rename box for the user to rename the tab title
6072
// - We automatically use the previous title as the initial text of the box

src/cascadia/TerminalApp/TabHeaderControl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace winrt::TerminalApp::implementation
1818
void RenameBoxLostFocusHandler(winrt::Windows::Foundation::IInspectable const& sender,
1919
winrt::Windows::UI::Xaml::RoutedEventArgs const& e);
2020

21+
bool InRename();
22+
2123
WINRT_CALLBACK(TitleChangeRequested, TerminalApp::TitleChangeRequestedArgs);
2224

2325
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);

src/cascadia/TerminalApp/TabHeaderControl.idl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ namespace TerminalApp
1414
TabHeaderControl();
1515
void BeginRename();
1616

17+
Boolean InRename { get; };
18+
1719
TerminalTabStatus TabStatus { get; set; };
1820

1921
event TitleChangeRequestedArgs TitleChangeRequested;

src/cascadia/TerminalApp/TerminalTab.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,13 @@ namespace winrt::TerminalApp::implementation
870870
contextMenuFlyout.Closed([weakThis](auto&&, auto&&) {
871871
if (auto tab{ weakThis.get() })
872872
{
873-
tab->_RequestFocusActiveControlHandlers();
873+
// GH#10112 - if we're opening the tab renamer, don't
874+
// immediately toss focus to the control. We don't want to steal
875+
// focus from the tab renamer.
876+
if (!tab->_headerControl.InRename())
877+
{
878+
tab->_RequestFocusActiveControlHandlers();
879+
}
874880
}
875881
});
876882
_AppendCloseMenuItems(contextMenuFlyout);

0 commit comments

Comments
 (0)