Skip to content

Commit 8c910fa

Browse files
committed
Ensure tab get focus if the container can't get focus.
1 parent be0832f commit 8c910fa

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Terminal.Gui/Views/TabView/TabView.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public Tab? SelectedTab
142142

143143
if (old != _selectedTab)
144144
{
145-
if (_selectedTabHasFocus || !_containerView.CanFocus)
145+
if (TabCanSetFocus ())
146146
{
147147
SelectedTab?.SetFocus ();
148148
}
@@ -153,6 +153,11 @@ public Tab? SelectedTab
153153
}
154154
}
155155

156+
private bool TabCanSetFocus ()
157+
{
158+
return IsInitialized && SelectedTab is { } && (_selectedTabHasFocus || !_containerView.CanFocus);
159+
}
160+
156161
private void ContainerViewCanFocus (object sender, EventArgs eventArgs)
157162
{
158163
_containerView.CanFocus = _containerView.Subviews.Count (v => v.CanFocus) > 0;
@@ -509,7 +514,7 @@ internal IEnumerable<Tab> CalculateViewport (Rectangle bounds)
509514
i += tabTextWidth + 1;
510515
}
511516

512-
if (_selectedTabHasFocus)
517+
if (TabCanSetFocus ())
513518
{
514519
SelectedTab?.SetFocus ();
515520
}

0 commit comments

Comments
 (0)