MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[Feature]: Add an option to enable only text options in the default context menus

Open
#4,189 3 comments 1 reaction 2 assignees View on GitHub

@Lakshmisha-KS is already working on this.

Since Feb 12, 2025.

feature request
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Describe the feature/enhancement you need

Currently, there exists an option called AreDefaultContextMenusEnabled which can be set to true or false to enable or disable default context menus in the WebView2. The problem is, often it is desirable to disable various in-built context menu options such as Save as, web capture, copy link, open in new window, etc. while still enabling text options such as Cut, Copy and Paste - in fact, this is the default behaviour of the Microsoft Edge based UWP WebView - it shows only text options in its context menus.

UWP WebView context menu with a link selected:
image

WebView2 context menu with a link selected:
image

The scenario/use case where you would use this feature

This would be useful as in many situations that require a web view, developers want to remove normal browsers items such as the option to open links in new windows, use web capture, etc. but still allow users to copy and paste text from the context menu like the UWP WebView. An example of this could be an in app help manual where these extra options do not make sense but the user may still want to copy text (for example, the user manual might have example input data for the app that the user may want to copy and past into the app). Microsoft's own Get Help app might find this feature useful as well as it disables the default WebView2 context menus but there is a search text box which currently has no context menu and as a user I think it would be beneficial to have a Cut, Copy Paste context menu for that text box.

How important is this request to you?

Nice to have. There are other ways to tackle this, but having official API support would be beneficial.

Suggested implementation

At the moment, it is possible to customise the default context menus using the items' names to identify them, however, as far as I know, there is no official documentation that describes the names of the default context menu items and so, as a developer, I am unsure if they might change in the future or if we should be using them. Additionally, since this is such a common scenario, I think it would be beneficial for this to be an option that can be opted into, as that would be much quicker than customising the menu manually. This could also help with migrating from the old UWP WebView, as, when enabled, it would match the context menu behaviour to that of the old UWP WebView. Also, on the topic of the names, see this issue: https://github.com/MicrosoftEdge/WebView2Feedback/issues/3297.

What does your app do? Is there a pending deadline for this request?

No response

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.