Skip to content

Commit

Permalink
Support ElementReference.Focus in WebView (#31050)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSandersonMS authored Mar 19, 2021
1 parent 8cc970c commit 6167a22
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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

0 comments on commit 6167a22

Please sign in to comment.