MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Webview2 Windows Close Button Mouse Hover Highlight is still enabled while mouse is over WebView Control

Open
#3,159 3 comments 0 reactions 1 assignee View on GitHub

@champnic is already working on this.

Since Jan 26, 2023.

bug priority-low tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description
While using a <Window.Template> Windows Close Button is still highlighted after the user moves their mouse from the close button to the WebView. (Template Code will be provided below)

Version
SDK: WebView2 1.0.1518.46
Runtime: WebView2.FixedVersionRuntime.109.0.1518.52.x64
Framework: WPF .NET 6.0
OS: Win10

Repro Steps

  1. Create a basic C# WPF .NET 6 Webview2 application
  2. In the MainWindow enable the Webview2 control and have it navigate to any web page (Code Below)
  3. Run the application
  4. After navigating to your web page, hover your mouse over the Close Button to see it highlight
  5. From there, move your mouse downward towards the Webview2 Control

Expected: Close Button will stop highlighting once your mouse leaves the button bounds

Actual: Close Button will continue to be highlighted until their mouse reaches the title bar

Additional context
Setting a higher Height to the title bar so there is some title bar between the Close Button and the WebView2 control does not work if the user is moving their mouse downward fast.

MainWindow Code

MainWindow.xaml

<Window x:Class="Webview_App.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Webview_App" xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <WindowChrome.WindowChrome>
        <WindowChrome GlassFrameThickness="-1" ResizeBorderThickness="0" CaptionHeight="30" NonClientFrameEdges="None" UseAeroCaptionButtons="True" />
    </WindowChrome.WindowChrome>
    <Window.Template>
        <ControlTemplate>
            <Grid Name="CustomTitleBar">
                <Grid.RowDefinitions>
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="1*"/>
                </Grid.RowDefinitions>

                <Border Grid.Row="0" Opacity="1.0">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="30" />
                            <ColumnDefinition Width="1*"/>
                        </Grid.ColumnDefinitions>

                        <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,0,30,0">
                            <!-- Window Title - Center Aligned -->
                            <TextBlock
                                TextAlignment="Center" 
                                VerticalAlignment="Center"
                                Text="{Binding Title, RelativeSource={RelativeSource TemplatedParent}}" FontFamily="Segoe UI Semibold" />
                        </StackPanel>

                    </Grid>
                </Border>
                
                <Border Grid.Row="1" Background="White" Opacity="1.0" Margin="0,0,0,0">
                    <ContentPresenter Content="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}"/>
                </Border>
            </Grid>
        </ControlTemplate>
    </Window.Template>
    <Grid>
        <wv2:WebView2 Name="CustomWebView" />
    </Grid>
</Window>

MainWindow.cs

using System;
using System.Diagnostics;
using System.Windows;

namespace Webview_App
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            Dispatcher.BeginInvoke(new Action(() => InitializeWebView2Async()));
        }

        private async void InitializeWebView2Async()
        {
            try
            {
                await this.CustomWebView.EnsureCoreWebView2Async();
                this.CustomWebView.CoreWebView2.Navigate("https://microsoft.com/");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("failed to initialize webview");
            }
        }
    }
}

AB#43482343

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.