Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting AreBrowserAcceleratorKeysEnabled does not have effect #19419

Closed
paulvanbladel opened this issue Dec 14, 2023 · 4 comments
Closed

setting AreBrowserAcceleratorKeysEnabled does not have effect #19419

paulvanbladel opened this issue Dec 14, 2023 · 4 comments
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView external partner/webview2 Issues depending on Edge WebView2 platform/windows 🪟 t/bug Something isn't working

Comments

@paulvanbladel
Copy link

paulvanbladel commented Dec 14, 2023

Description

I want to disable F5 based refresh in an maui hybrid blazor app by means of setting AreBrowserAcceleratorKeysEnabled = false.
That doesn't seem to work.
The strange this is that setting other settings like IsZoomControlEnabled does work.

Steps to Reproduce

Start in visual studio a standard maui hybrid blazor app.
We need to and event handler to blazor webview and set the setting in the event handler.

Add BlazorWebViewInitialized event handler in Mainpage.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:MauiApp1"
             x:Class="MauiApp1.MainPage"
             BackgroundColor="{DynamicResource PageBackgroundColor}">

    <BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html" BlazorWebViewInitialized="blazorWebView_BlazorWebViewInitialized">
        <BlazorWebView.RootComponents >
            <RootComponent Selector="#app" ComponentType="{x:Type local:Routes}" />
        </BlazorWebView.RootComponents>
    </BlazorWebView>

</ContentPage>
        private void blazorWebView_BlazorWebViewInitialized(object sender, Microsoft.AspNetCore.Components.WebView.BlazorWebViewInitializedEventArgs e)
        {
#if WINDOWS
            e.WebView.CoreWebView2.Settings.IsZoomControlEnabled = false; // THIS WORKS
            e.WebView.CoreWebView2.Settings.AreBrowserAcceleratorKeysEnabled = false; // THIS DOES NOT WORK
#endif
        }

Link to public reproduction project repository

No response

Version with bug

8.0.3

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

maui-windows 8.0.3/8.0.100 VS 17.8.34322.80

Did you find any workaround?

No response

Relevant log output

No response

@paulvanbladel paulvanbladel added the t/bug Something isn't working label Dec 14, 2023
@jfversluis
Copy link
Member

Setting through a custom mapper also doesn't have any effect:

BlazorWebViewHandler.BlazorWebViewMapper.AppendToMapping("NoAccelerators", async (handler, view) =>
{
    await handler.PlatformView.EnsureCoreWebView2Async();
    if (handler.PlatformView.CoreWebView2 is not null)
    {
        handler.PlatformView.CoreWebView2.Settings.AreBrowserAcceleratorKeysEnabled = false;
    }
});

@jfversluis jfversluis added the area-blazor Blazor Hybrid / Desktop, BlazorWebView label Dec 14, 2023
@Eilon
Copy link
Member

Eilon commented Dec 14, 2023

The same API doesn't seem to work in a plain WinUI app with WebView2 either.

@Eilon
Copy link
Member

Eilon commented Dec 14, 2023

Works in WPF WebView2.

@Eilon Eilon added the partner/webview2 Issues depending on Edge WebView2 label Dec 14, 2023
@Eilon
Copy link
Member

Eilon commented Dec 14, 2023

I filed MicrosoftEdge/WebView2Feedback#4241 because this appears to be an issue with WebView2 itself and not in .NET MAUI or BlazorWebView. Please add any additional comments/votes/details to that issue.

@Eilon Eilon closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2023
@Eilon Eilon added the external label Dec 14, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView external partner/webview2 Issues depending on Edge WebView2 platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants