Skip to content

WebView2 focus trap on UWP XBOX when using XY directional navigation #4284

Open
@LDS2020

Description

@LDS2020

What happened?

While testing the WebView2 WinUI2 Sample on Xbox, along with an app I have in the MS Store, I find that I am unable to disengage from the WV2 control when using XY directional navigation. I am not sure if this is an implementation issue in the Sample or a bug in WebView2 for Xbox. I find it hard to believe this issue didn't get picked up in testing, so I am starting here.

  • The existing UWP sample works fine on Xbox but it uses Mouse or Pointer mode, which allows the users to move from the Webview to other controls on the page. An Xbox app, however, would normally use XY navigation which allows full access to every button on the Gamepad and is the #1 best practice for Xbox UI.

  • When you switch to XY navigation, the user gets stuck in a a focus trap on the WebView2 control and cannot disengage by pressing the B button which is how most controls (like the address bar in this sample or the original WebView1) work. The only way to exit is click the Xbox button, Quit the app and start again.

Importance
Blocking. Although it is theoretically possible to switch Xbox apps over to Mouse mode, it would require major changes for developers and a foreign user experience for the users.

Environment

Runtime Channel
Stable release (WebView2 Runtime)

Runtime Version
Pre-installed on Xbox

WebView2 Version
1.0.2210.55

Framework
WinUI2/UWP
Microsoft.UI.Xaml 2.8.6

Operating System
Xbox

OS Version
10.0.25398.2921

Repro steps

  • See this modified repo of the WebView2 WinUI2 sample app, where I have:

  • Switched to XY Navigation Mode by changing PointerMode to WhenRequested in App.xaml.cs

  • Turned on Reveal Focus and written debug lines, so you can see which control has focus

  • Disabled scaling to avoid the bug documented in WebView2 issue 4133 by @remokeitel

  • Set IsFocusEngagementEnabled=true, RequiresPointer=true and set IsFocusEngaged=true for the WebView2 control

Expected behavior

The user should be able to navigate to the WebView2 on the page, select A to engage and interact with it using the temporary Mouse pointer, and select B to disengage so they can select another control, as described in this quote from here:

When the IsFocusEngagementEnabled property is set to true, it marks the control as requiring focus engagement. This means that the user must press the A/Select button to "engage" the control and interact with it. When they are finished, they can press the B/Back button to disengage the control and navigate away from it.

Instead, the user is stuck on the WebView control, as shown in this screenshot, and cannot get to any of the other controls on the page or use any of the buttons on the gamepad:

WinUi2 WebView2 example

Related Issue
A separate but related issue is that WebView2 for WinUi2 has not yet implemented Key events like OnPreviewKeyDown, as has been done on other platforms, so it is not possible to intercept the B button inside the Webview2 to code a workaround.

AB#48450583

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtrackedWe are tracking this work internally.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions