Skip to content

Commit

Permalink
Also do the VisualState dance on the tab item (#15217)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zadjii-msft authored Apr 24, 2023
1 parent 4788347 commit ee05307
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/cascadia/TerminalApp/TabBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit ee05307

Please sign in to comment.