microsoft-ui-xaml: Unable to Interact with WebView in WinUI 2.6

Describe the bug Unable to interact with Contents of WebView. (Clicking Links, Scrolling etc.) This does not exist when downgrading to 2.5.0

Steps to reproduce the bug This from XAML Controls Gallery <WebView Source="https://docs.microsoft.com/en-us/windows/uwp/design/controls-and-patterns/web-view" /> you won’t be able to scroll/click any of the links Can observe this behavior in the XAML Controls Gallery App itself.

Expected behavior Can Interact with WebView like 2.5.0

Version Info NuGet package version: [Microsoft.UI.Xaml 2.6.0]

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
19043 Yes
October 2020 Update (19042)
May 2020 Update (19041)
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 27 (9 by maintainers)

Most upvoted comments

Looks like the rounding of the navigation view content area is causing this issue in certain OS versions.

As a workaround, setting NavigationViewContentGridCornerRadius to 0 might mitigate this issue. https://docs.microsoft.com/en-us/windows/apps/design/style/mica#standard-pattern-in-top-navigationview

I found how to fix it! You can’t set BorderBush and CornerRadius in same time, or the WebView will can’t be clicked. You can just remove the BorderBush, then you can use WebView with CornerRadius now. Like this https://github.com/Coolapk-UWP/Coolapk-UWP/blob/revived/CoolapkUWP/CoolapkUWP/Controls/NavigationView/NavigationView.xaml#L20-L709

<SplitView.Content>
    <Border
        x:Name="ContentBorder"
        Margin="{ThemeResource NavigationViewContentMargin}"
        CornerRadius="{ThemeResource NavigationViewContentGridCornerRadius}">
        <Grid
            x:Name="ContentGrid"
            Background="{ThemeResource NavigationViewContentBackground}"
            BorderBrush="{ThemeResource NavigationViewContentGridBorderBrush}"
            BorderThickness="{ThemeResource NavigationViewContentGridBorderThickness}">
...

@huynhsontung interesting, I just created a new project as well (min 17763, target 19041) on my 19043.1052 windows version and it worked fine. Just added the WinUI 2.6 NuGet and resources, and just added a WebView within the Grid of the MainPage…

If I instead put the WebView in a new page, and add a NavigationView to my main page with a Frame:

    <muxc:NavigationView x:Name="nvSample" SelectionChanged="nvSample_SelectionChanged">
        <muxc:NavigationView.MenuItems>
            <muxc:NavigationViewItem Content="Menu Item1" Icon="Play" Tag="SamplePage1" />
            <muxc:NavigationViewItem Content="Menu Item2" Icon="Save" Tag="SamplePage2" />
        </muxc:NavigationView.MenuItems>
        <Frame x:Name="contentFrame" />
    </muxc:NavigationView>
        private void nvSample_SelectionChanged(Microsoft.UI.Xaml.Controls.NavigationView sender, Microsoft.UI.Xaml.Controls.NavigationViewSelectionChangedEventArgs args)
        {
            if (args.SelectedItemContainer.Tag.ToString() == "SamplePage2")
            {
                contentFrame.Navigate(typeof(WebPage));
            }
        }

And then re-run the app, I can click on the 2nd item, and enter the invalid state where the WebView won’t respond to mouse input.

(If I instead just have the Frame be part of my main page and navigate to the secondary page it works fine. So it seems definitely related to having a NavigationView in the tree which is interrupting how WebView works on at least 19042/19043 OSes.)

Edit: Also, if I use the same project and just install WinUI 2.6.0-prerelease.210113001 it works fine as well.

WinUI Version WebView Functional?
2.6.0-prerelease.210113001 Works
2.6.0-prerelease.210430001 Works
2.6.0-prerelease.210623001 Doesn’t Work
2.6.0 Doesn’t Work

So something with the new style introduction between 210430001 and 210623001 broke how WebView works within NavigationView.

Currently blocking upgrade of React Native for Windows to 2.6 - can we get this tagged as RNW too?