MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Multiple WebView2 control have focus sometimes.

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

@victorhuangwq is already working on this.

Since Nov 20, 2023.

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

Description

Description

I'm using multiple WebView2 control in WPF application.
It seems that multiple WebView2 control have focus sometimes.
Would you please check it?

Version
SDK: WebView2 1.0.1518.46
Runtime: Microsoft.Web.WebView2 1.0.1518.46
Framework: WPF, .Net6
OS: Win10

Repro Steps

I made a simple app as the following.

  1. Launch app.
  2. Press "F2" key.
    --> Sub window is shown.
  3. Set cursor to "Search" Textbox in the following order.
    View1 -> View2 -> Sub window -> View2
    --> Cursor is blinking in both View1 and View2.
<Window
    x:Class="WpfApp17.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
    Title="Test"
    MinWidth="250"
    WindowStartupLocation="CenterScreen">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <wv2:WebView2 x:Name="View1" Source="https://docs.microsoft.com/en-us/" />
        <wv2:WebView2 x:Name="View2" Grid.Row="1" Source="https://docs.microsoft.com/en-us/" />
    </Grid>
</Window>

Code behind

using Microsoft.Web.WebView2.Wpf;
using System;
using System.Windows;
using System.Windows.Input;

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

        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            if (e.Key == Key.F2)
            {
                var w = new Window();
                w.Width = 500;
                w.Height = 400;

                var webView = new WebView2() { Title = "Sub window" };
                webView.Source = new Uri("https://docs.microsoft.com/en-us/");
                w.Content = webView;

                w.Owner = this;
                w.Show();
            }
        }
    }
}

Screenshots
image

Additional context

AB#43457303

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.