Skip to content

Commit 24f80bd

Browse files
authored
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
1 parent e3d673e commit 24f80bd

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
@@ -899,7 +899,13 @@ namespace winrt::TerminalApp::implementation
899899
contextMenuFlyout.Closed([weakThis](auto&&, auto&&) {
900900
if (auto tab{ weakThis.get() })
901901
{
902-
tab->_RequestFocusActiveControlHandlers();
902+
// GH#10112 - if we're opening the tab renamer, don't
903+
// immediately toss focus to the control. We don't want to steal
904+
// focus from the tab renamer.
905+
if (!tab->_headerControl.InRename())
906+
{
907+
tab->_RequestFocusActiveControlHandlers();
908+
}
903909
}
904910
});
905911
_AppendCloseMenuItems(contextMenuFlyout);

0 commit comments

Comments
 (0)