Skip to content

Commit ccc7379

Browse files
gave92Marco Gavelli
authored andcommitted
Fix webview scrollbars in dark mode
1 parent 9e5df75 commit ccc7379

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

src/Files.App/Terminal/UI/Build/src/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<link rel="stylesheet" href="xterm.css" />
77
<link rel="stylesheet" href="style.css" />
88
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
9+
<meta name="color-scheme" content="dark light">
910
</head>
1011

1112
<body>

src/Files.App/Terminal/UI/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<link rel="stylesheet" href="xterm.css" />
77
<link rel="stylesheet" href="style.css" />
88
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
9+
<meta name="color-scheme" content="dark light">
910
</head>
1011

1112
<body>

src/Files.App/UserControls/TerminalView.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ private async void WebViewControl_LoadedAsync(object sender, Microsoft.UI.Xaml.R
144144
var theme = provider.GetPreInstalledThemes().First(x => x.Id == profile.TerminalThemeId);
145145

146146
WebViewControl.DefaultBackgroundColor = ColorHelpers.FromHex(theme.Colors.Background);
147+
WebViewControl.CoreWebView2.Profile.PreferredColorScheme = (ActualTheme == Microsoft.UI.Xaml.ElementTheme.Dark) ? CoreWebView2PreferredColorScheme.Dark : CoreWebView2PreferredColorScheme.Light;
147148

148149
var size = await CreateXtermViewAsync(options, theme.Colors,
149150
keyBindings.Values.SelectMany(k => k)).ConfigureAwait(false);
@@ -479,7 +480,10 @@ private async void TerminalView_ActualThemeChanged(Microsoft.UI.Xaml.FrameworkEl
479480
theme.Colors.Foreground = foregroundColor;
480481
theme.Colors.CursorAccent = backgroundColor;
481482
theme.Colors.Cursor = foregroundColor;
483+
482484
WebViewControl.DefaultBackgroundColor = ColorHelpers.FromHex(backgroundColor);
485+
WebViewControl.CoreWebView2.Profile.PreferredColorScheme = (ActualTheme == Microsoft.UI.Xaml.ElementTheme.Dark) ? CoreWebView2PreferredColorScheme.Dark : CoreWebView2PreferredColorScheme.Light;
486+
483487
var serializedTheme = JsonConvert.SerializeObject(theme.Colors, serializerSettings);
484488
await ExecuteScriptAsync($"changeTheme('{serializedTheme}')");
485489
}

0 commit comments

Comments
 (0)