Skip to content
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

Support ElementReference.Focus in WebView #31050

Merged
merged 1 commit into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Components/WebView/WebView/src/PageContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public PageContext(
JSRuntime.AttachToWebView(ipcSender);

var loggerFactory = services.GetRequiredService<ILoggerFactory>();
Renderer = new WebViewRenderer(services, dispatcher, ipcSender, loggerFactory);
Renderer = new WebViewRenderer(services, dispatcher, ipcSender, loggerFactory, JSRuntime.ElementReferenceContext);
}

public void Dispose()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ internal class WebViewJSRuntime : JSRuntime
{
private IpcSender _ipcSender;

public ElementReferenceContext ElementReferenceContext { get; }

public WebViewJSRuntime()
{
ElementReferenceContext = new WebElementReferenceContext(this);
JsonSerializerOptions.Converters.Add(
new ElementReferenceJsonConverter(
new WebElementReferenceContext(this)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ public WebViewRenderer(
IServiceProvider serviceProvider,
Dispatcher dispatcher,
IpcSender ipcSender,
ILoggerFactory loggerFactory) :
ILoggerFactory loggerFactory,
ElementReferenceContext elementReferenceContext) :
base(serviceProvider, loggerFactory)
{
_dispatcher = dispatcher;
_ipcSender = ipcSender;
ElementReferenceContext = elementReferenceContext;
}

public override Dispatcher Dispatcher => _dispatcher;
Expand Down