BlazorWebView WPF tab navigation improvements #7742
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
Prior to this PR, the WPF
BlazorWebView
was not correctly handling tab navigation. TheBlazorWebView
control itself was participating in tab navigation in accordance with itsIsTabStop
andTabIndex
properties, but its subtree (the underlying WebView2 control and its focusable HTML elements) was always last in the tab sequence and unaffected by those properties.This PR changes the WPF
BlazorWebView
tab navigation behavior in the following ways:BlazorWebView
control itself cannot receive focus, but its children can. Prior to this change, using<tab>
to move the focus from a control outside the WebView to the first HTML element inside the WebView required two presses, since the first press moved focus to theBlazorWebView
container and the second press moved it to the first child.IsTabStop="False"
on theBlazorWebView
would remove the container from the tab sequence, but not its children. Now, doing this removes all theBlazorWebView
's children from the normal tab sequence. If you manually give an HTML element focus (e.g. by clicking it), you can navigate the webpage using the keyboard, but as soon as keyboard navigation escapes theBlazorWebView
, it will stay that way (unless focus is somehow given to an HTML element again).Issues Fixed
Fixes #2537