MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: When using an SVG format image as a menu item icon, it does not appear to be displayed.
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
Discussed in https://github.com/MicrosoftEdge/WebView2Feedback/discussions/4543
Originally posted by Yookey May 8, 2024
Hello:
I created a custom menu item using the following code, but it cannot display SVG format vector icons (bitmap icons can be displayed normally). I carefully read the development documentation, which clearly indicates that SVG format images can be used.
did I make a mistake somewhere?
doc:
https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2contextmenuitem.icon?view=webview2-dotnet-1.0.2194-prerelease#microsoft-web-webview2-core-corewebview2contextmenuitem-icon
Importance
Moderate. My app's user experience is affected, but still usable.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
128.0.2739.79
SDK Version
1.0.2739.15
Framework
Winforms
Operating System
Windows 11
OS Version
10.0.22631.4169
Repro steps
private void CoreWebView2_ContextMenuRequested(object sender, CoreWebView2ContextMenuRequestedEventArgs e)
{
e.MenuItems.Clear();
if (e.ContextMenuTarget.HasSelection && !string.IsNullOrEmpty(e.ContextMenuTarget.SelectionText.Trim('\n')))
{
var item = webViewer.CoreWebView2.Environment.CreateContextMenuItem("Copy Text", GetIcon(iconName), CoreWebView2ContextMenuItemKind.Command);
e.MenuItems.Add(item);
}
}
Stream GetIcon(string iconName)
{
if (string.IsNullOrWhiteSpace(iconName)) return null;
if (Icons.ContainsKey(iconName))
return Icons[iconName];
else
{
var bytes = UILayer.Properties.Resources.reply; // <--- this is a test image in SVG format
Stream stream = new MemoryStream(bytes) {
Position = 0
};
Icons.Add(iconName, stream);
return stream;
}
}
Repros in Edge Browser
No, issue does not reproduce in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied WinForms reproduction around CoreWebView2_ContextMenuRequested, CreateContextMenuItem, and the GetIcon stream, then compare the behavior with the CoreWebView2ContextMenuItem.Icon documentation. Done means establishing why the SVG icon is not displayed in the stated WebView2 runtime and identifying a documented resolution or confirmed product fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100