dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.98k stars 1.72k forks source link

WebView Right Click & Navigation requested notification #12751

Open BalajiSubramaniam opened 1 year ago

BalajiSubramaniam commented 1 year ago

Right Click Ability to show a native context menu, where menu items are defined in XAML/C#, for the WebView when a right click is performed. Use Cases :

Navigation Requested (decision-making) Notify when navigation is being requested providing the option to allow or cancel. Intent is to support the concept of whitelisting and provide ability to review each requested URL to allow or cancel navigation accordingly. Use Cases :

Axemasta commented 1 year ago

The functionality you describe is something that the developer would want to implement within your application. I built a browser based app in Xamarin Forms with exactly the features you described: Ability to decide whether to navigate to allowed urls / domains.

You can use the WebView.Navigating event to determine this functionality.

The Xamarin implementation was plagued by a bug where navigating decisions wouldn't work with tasks, this is due to how that renderer was implemented (using an old school WPF pattern to cancel the navigation). This bug (more like design oversight) has been ported to MAUI, I raised this in Xamarin & Maui repos years ago at this point, I even did a PR for Xamarin but it got ignored due to the feature freeze of XF 5.

The workaround in Xamarin is to use my forked SuperWebView control which is the code from Xamarin, ported to another library and then altered to allow asynchronous web request cancellation. I didn't plan on porting the control to MAUI but it looks like I might have to since there appears to be no activity on community contributions, which is a shame.

jsuarezruiz commented 1 year ago

You can find a sample to achieve something similar here https://github.com/dotnet/maui/blob/main/src/Controls/samples/Controls.Sample/Pages/Core/ContextFlyoutPage.xaml#L122

ghost commented 1 year ago

Hi @BalajiSubramaniam. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.