Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also do the VisualState dance on the tab item #15217

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}