Skip to content

Commit c8ab75b

Browse files
committed
Revert "In specific scenarios, focus the active control (#10048)"
This reverts commit b345d39.
1 parent b345d39 commit c8ab75b

File tree

7 files changed

+16
-68
lines changed

7 files changed

+16
-68
lines changed

src/cascadia/TerminalApp/SettingsTab.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ namespace winrt::TerminalApp::implementation
6262
// - <none>
6363
void SettingsTab::_MakeTabViewItem()
6464
{
65-
TabBase::_MakeTabViewItem();
66-
65+
TabViewItem(::winrt::MUX::Controls::TabViewItem{});
6766
Title(RS_(L"SettingsTab"));
6867
TabViewItem().Header(winrt::box_value(Title()));
6968
}

src/cascadia/TerminalApp/SettingsTab.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace winrt::TerminalApp::implementation
3333
void Focus(winrt::Windows::UI::Xaml::FocusState focusState) override;
3434

3535
private:
36-
void _MakeTabViewItem() override;
36+
void _MakeTabViewItem();
3737
winrt::fire_and_forget _CreateIcon();
3838
};
3939
}

src/cascadia/TerminalApp/TabBase.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,9 @@ namespace winrt::TerminalApp::implementation
4646
auto weakThis{ get_weak() };
4747

4848
// Build the menu
49-
Controls::MenuFlyout contextMenuFlyout;
50-
// GH#5750 - When the context menu is dismissed with ESC, toss the focus
51-
// back to our control.
52-
contextMenuFlyout.Closed([weakThis](auto&&, auto&&) {
53-
if (auto tab{ weakThis.get() })
54-
{
55-
tab->_RequestFocusActiveControlHandlers();
56-
}
57-
});
58-
_AppendCloseMenuItems(contextMenuFlyout);
59-
TabViewItem().ContextFlyout(contextMenuFlyout);
49+
Controls::MenuFlyout newTabFlyout;
50+
_AppendCloseMenuItems(newTabFlyout);
51+
TabViewItem().ContextFlyout(newTabFlyout);
6052
}
6153

6254
// Method Description:
@@ -233,24 +225,4 @@ namespace winrt::TerminalApp::implementation
233225
toolTip.Content(textBlock);
234226
WUX::Controls::ToolTipService::SetToolTip(TabViewItem(), toolTip);
235227
}
236-
237-
// Method Description:
238-
// - Initializes a TabViewItem for this Tab instance.
239-
// Arguments:
240-
// - <none>
241-
// Return Value:
242-
// - <none>
243-
void TabBase::_MakeTabViewItem()
244-
{
245-
TabViewItem(::winrt::MUX::Controls::TabViewItem{});
246-
247-
// GH#3609 If the tab was tapped, and no one else was around to handle
248-
// it, then ask our parent to toss focus into the active control.
249-
TabViewItem().Tapped([weakThis{ get_weak() }](auto&&, auto&&) {
250-
if (auto tab{ weakThis.get() })
251-
{
252-
tab->_RequestFocusActiveControlHandlers();
253-
}
254-
});
255-
}
256228
}

src/cascadia/TerminalApp/TabBase.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ namespace winrt::TerminalApp::implementation
2525
void UpdateTabViewIndex(const uint32_t idx, const uint32_t numTabs);
2626
void SetKeyMap(const Microsoft::Terminal::Settings::Model::KeyMapping& keymap);
2727

28-
WINRT_CALLBACK(RequestFocusActiveControl, winrt::delegate<void()>);
29-
3028
WINRT_CALLBACK(Closed, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>);
3129
WINRT_CALLBACK(CloseRequested, winrt::Windows::Foundation::EventHandler<winrt::Windows::Foundation::IInspectable>);
3230
WINRT_CALLBACK(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
@@ -54,8 +52,6 @@ namespace winrt::TerminalApp::implementation
5452
virtual void _CreateContextMenu();
5553
virtual winrt::hstring _CreateToolTipTitle();
5654

57-
virtual void _MakeTabViewItem();
58-
5955
void _AppendCloseMenuItems(winrt::Windows::UI::Xaml::Controls::MenuFlyout flyout);
6056
void _EnableCloseMenuItems();
6157
void _CloseTabsAfter();

src/cascadia/TerminalApp/TabManagement.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ namespace winrt::TerminalApp::implementation
210210
}
211211
});
212212

213-
// The tab might want us to toss focus into the control, especially when
214-
// transient UIs (like the context menu, or the renamer) are dismissed.
215-
newTabImpl->RequestFocusActiveControl([weakThis{ get_weak() }]() {
213+
newTabImpl->TabRenamerDeactivated([weakThis{ get_weak() }](auto&& /*s*/, auto&& /*e*/) {
216214
if (const auto page{ weakThis.get() })
217215
{
218216
page->_FocusCurrentTab(false);

src/cascadia/TerminalApp/TerminalTab.cpp

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,6 @@ namespace winrt::TerminalApp::implementation
5353
}
5454
});
5555

56-
// GH#9162 - when the header is done renaming, ask for focus to be
57-
// tossed back to the control, rather into ourselves.
58-
_headerControl.RenameEnded([weakThis = get_weak()](auto&&, auto&&) {
59-
if (auto tab{ weakThis.get() })
60-
{
61-
tab->_RequestFocusActiveControlHandlers();
62-
}
63-
});
64-
6556
_UpdateHeaderControlMaxWidth();
6657

6758
// Use our header control as the TabViewItem's header
@@ -92,7 +83,7 @@ namespace winrt::TerminalApp::implementation
9283
// - <none>
9384
void TerminalTab::_MakeTabViewItem()
9485
{
95-
TabBase::_MakeTabViewItem();
86+
TabViewItem(::winrt::MUX::Controls::TabViewItem{});
9687

9788
TabViewItem().DoubleTapped([weakThis = get_weak()](auto&& /*s*/, auto&& /*e*/) {
9889
if (auto tab{ weakThis.get() })
@@ -858,23 +849,14 @@ namespace winrt::TerminalApp::implementation
858849
}
859850

860851
// Build the menu
861-
Controls::MenuFlyout contextMenuFlyout;
852+
Controls::MenuFlyout newTabFlyout;
862853
Controls::MenuFlyoutSeparator menuSeparator;
863-
contextMenuFlyout.Items().Append(chooseColorMenuItem);
864-
contextMenuFlyout.Items().Append(renameTabMenuItem);
865-
contextMenuFlyout.Items().Append(duplicateTabMenuItem);
866-
contextMenuFlyout.Items().Append(menuSeparator);
867-
868-
// GH#5750 - When the context menu is dismissed with ESC, toss the focus
869-
// back to our control.
870-
contextMenuFlyout.Closed([weakThis](auto&&, auto&&) {
871-
if (auto tab{ weakThis.get() })
872-
{
873-
tab->_RequestFocusActiveControlHandlers();
874-
}
875-
});
876-
_AppendCloseMenuItems(contextMenuFlyout);
877-
TabViewItem().ContextFlyout(contextMenuFlyout);
854+
newTabFlyout.Items().Append(chooseColorMenuItem);
855+
newTabFlyout.Items().Append(renameTabMenuItem);
856+
newTabFlyout.Items().Append(duplicateTabMenuItem);
857+
newTabFlyout.Items().Append(menuSeparator);
858+
_AppendCloseMenuItems(newTabFlyout);
859+
TabViewItem().ContextFlyout(newTabFlyout);
878860
}
879861

880862
// Method Description:

src/cascadia/TerminalApp/TerminalTab.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ namespace winrt::TerminalApp::implementation
9090
DECLARE_EVENT(ColorCleared, _colorCleared, winrt::delegate<>);
9191
DECLARE_EVENT(TabRaiseVisualBell, _TabRaiseVisualBellHandlers, winrt::delegate<>);
9292
DECLARE_EVENT(DuplicateRequested, _DuplicateRequestedHandlers, winrt::delegate<>);
93+
FORWARDED_TYPED_EVENT(TabRenamerDeactivated, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, (&_headerControl), RenameEnded);
9394

9495
private:
9596
std::shared_ptr<Pane> _rootPane{ nullptr };
@@ -117,7 +118,7 @@ namespace winrt::TerminalApp::implementation
117118
std::optional<Windows::UI::Xaml::DispatcherTimer> _bellIndicatorTimer;
118119
void _BellIndicatorTimerTick(Windows::Foundation::IInspectable const& sender, Windows::Foundation::IInspectable const& e);
119120

120-
void _MakeTabViewItem() override;
121+
void _MakeTabViewItem();
121122

122123
winrt::fire_and_forget _UpdateHeaderControlMaxWidth();
123124

0 commit comments

Comments
 (0)