MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Some CSS styles can't be set using ExecuteScriptAsync?

Open
#2,483 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-low tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description
I can't seem to set any of the scrollbar CSS properties using ExecuteScriptAsync. This call works and sets the text colour to red:
await webview.ExecuteScriptAsync("document.body.style.color='#f00';");

But this call does nothing and no CSS styles are added to the body tag:
await webview.ExecuteScriptAsync("document.body.style.scrollbarFaceColor='#f00';");

These used to work with the old webview. My goal here is that our application has a light and a dark theme and if the user selects the dark theme we want to make the scrollbars dark in the WebView2 control as well.

Version
SDK: 1.0.1210.39
Runtime: Public channel v101.0.1210.53 (Official build) (64-bit)
Framework: .NET 6 Desktop
OS: Windows 11

Repro Steps
In the NavigationCompleted event handler just try using the 2 code examples above. The first one works and the second one does nothing.

Thanks for your help, keep up the great work!

AB#40023481

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the NavigationCompleted handler and the two ExecuteScriptAsync calls shown in the issue. Reproduce the working text-color change and the scrollbar-property change against the stated SDK and runtime versions, then determine whether the behavior is an API or CSS support limitation. Done means the supported behavior and any required workaround are documented or the defect is fixed and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.