Skip to content

Commit 791e8c8

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

File tree

7 files changed

+15
-67
lines changed

7 files changed

+15
-67
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(PropertyChanged, Windows::UI::Xaml::Data::PropertyChangedEventHandler);
3230

@@ -53,8 +51,6 @@ namespace winrt::TerminalApp::implementation
5351
virtual void _CreateContextMenu();
5452
virtual winrt::hstring _CreateToolTipTitle();
5553

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

src/cascadia/TerminalApp/TerminalPage.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,9 +866,7 @@ namespace winrt::TerminalApp::implementation
866866
}
867867
});
868868

869-
// The tab might want us to toss focus into the control, especially when
870-
// transient UIs (like the context menu, or the renamer) are dismissed.
871-
newTabImpl->RequestFocusActiveControl([weakThis{ get_weak() }]() {
869+
newTabImpl->TabRenamerDeactivated([weakThis{ get_weak() }](auto&& /*s*/, auto&& /*e*/) {
872870
if (const auto page{ weakThis.get() })
873871
{
874872
if (!page->_newTabButton.Flyout().IsOpen())

src/cascadia/TerminalApp/TerminalTab.cpp

Lines changed: 7 additions & 25 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() })
@@ -841,22 +832,13 @@ namespace winrt::TerminalApp::implementation
841832
}
842833

843834
// Build the menu
844-
Controls::MenuFlyout contextMenuFlyout;
835+
Controls::MenuFlyout newTabFlyout;
845836
Controls::MenuFlyoutSeparator menuSeparator;
846-
contextMenuFlyout.Items().Append(chooseColorMenuItem);
847-
contextMenuFlyout.Items().Append(renameTabMenuItem);
848-
contextMenuFlyout.Items().Append(menuSeparator);
849-
850-
// GH#5750 - When the context menu is dismissed with ESC, toss the focus
851-
// back to our control.
852-
contextMenuFlyout.Closed([weakThis](auto&&, auto&&) {
853-
if (auto tab{ weakThis.get() })
854-
{
855-
tab->_RequestFocusActiveControlHandlers();
856-
}
857-
});
858-
_AppendCloseMenuItems(contextMenuFlyout);
859-
TabViewItem().ContextFlyout(contextMenuFlyout);
837+
newTabFlyout.Items().Append(chooseColorMenuItem);
838+
newTabFlyout.Items().Append(renameTabMenuItem);
839+
newTabFlyout.Items().Append(menuSeparator);
840+
_AppendCloseMenuItems(newTabFlyout);
841+
TabViewItem().ContextFlyout(newTabFlyout);
860842
}
861843

862844
// Method Description:

src/cascadia/TerminalApp/TerminalTab.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ namespace winrt::TerminalApp::implementation
8989
DECLARE_EVENT(ColorSelected, _colorSelected, winrt::delegate<winrt::Windows::UI::Color>);
9090
DECLARE_EVENT(ColorCleared, _colorCleared, winrt::delegate<>);
9191
DECLARE_EVENT(TabRaiseVisualBell, _TabRaiseVisualBellHandlers, winrt::delegate<>);
92+
FORWARDED_TYPED_EVENT(TabRenamerDeactivated, winrt::Windows::Foundation::IInspectable, winrt::Windows::Foundation::IInspectable, (&_headerControl), RenameEnded);
9293

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

119-
void _MakeTabViewItem() override;
120+
void _MakeTabViewItem();
120121

121122
winrt::fire_and_forget _UpdateHeaderControlMaxWidth();
122123

0 commit comments

Comments
 (0)