-
Notifications
You must be signed in to change notification settings - Fork 705
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
Fix WebView2 focus getting stuck #7083
Conversation
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
// If the next element is this webview, then we are the only focusable element. Move focus back into the webview, | ||
// or else we'll get stuck trying to tab out of the top or bottom of the page instead of looping around. | ||
MoveFocusIntoCoreWebView(moveFocusRequestedReason); | ||
args.Handled(TRUE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems fine. What does CoreWebView2 do if we set args.Handled to FALSE -- does it automatically wrap, such that we maybe don't need to MoveFocusIntoCoreWebView()? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just setting it to FALSE did not automatically wrap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 Handy links: |
There was an issue where when a WebView2 was the only focusable element and the user tabbed through the content, the focus would get stuck at the end (or beginning) of the WebView2. This change prevents the issue by putting focus back in the webview.
Description
After moving focus all the way through a webview, at the end XAML will receive a MoveFocusRequested message where we would normally put focus on the next XAML element. However, in the case where the webview is the ONLY focusable element, focus did not go back to the webview. Instead, we should check if the next focusable element is the same webview that we're leaving, and if it is, put focus back in the WebView2 with a call to CoreWebView2Controller.MoveFocus(). This results in the focus moving from the end back up to the top, or when moving backwards, from the top back down to the end.
How Has This Been Tested?
This has been tested in a standalone app.