Also do the VisualState dance on the tab item (#15217)

Just changing the Theme also doesn't seem to work by itself - there
seems to be a way for the tab to set the deselected foreground onto
itself as it becomes selected. If the mouse isn't over the tab, that can
result in mismatched fg/bg's

Regressed around #15078 

Closes #15184
This commit is contained in:
Mike Griese
2023-04-24 16:41:10 -05:00
committed by GitHub
parent 478834756e
commit ee05307379

View File

@@ -558,17 +558,35 @@ namespace winrt::TerminalApp::implementation
// BODGY
// - Toggles the requested theme of the tab view item,
// so that changes to the tab color are reflected immediately
// - Prior to MUX 2.8, we toggled the visual state here, but that seemingly
// - Prior to MUX 2.8, we only toggled the visual state here, but that seemingly
// doesn't work in 2.8.
// - Just changing the Theme also doesn't seem to work by itself - there
// seems to be a way for the tab to set the deselected foreground onto
// itself as it becomes selected. If the mouse isn't over the tab, that
// can result in mismatched fg/bg's (see GH#15184). So that's right, we
// need to do both.
// Arguments:
// - <none>
// Return Value:
// - <none>
void TabBase::_RefreshVisualState()
{
const auto& item{ TabViewItem() };
const auto& reqTheme = TabViewItem().RequestedTheme();
TabViewItem().RequestedTheme(ElementTheme::Light);
TabViewItem().RequestedTheme(ElementTheme::Dark);
TabViewItem().RequestedTheme(reqTheme);
item.RequestedTheme(ElementTheme::Light);
item.RequestedTheme(ElementTheme::Dark);
item.RequestedTheme(reqTheme);
if (TabViewItem().IsSelected())
{
VisualStateManager::GoToState(item, L"Normal", true);
VisualStateManager::GoToState(item, L"Selected", true);
}
else
{
VisualStateManager::GoToState(item, L"Selected", true);
VisualStateManager::GoToState(item, L"Normal", true);
}
}
}