Skip to content
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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ List of added functionality in this release.

- The `Click` and `DoubleClick` extension methods now set the `MouseEventArgs.Detail` property to `1` and `2` respectively by default, unless the user specifies something else. This makes the methods more correctly emulate how Blazor reports single or double clicks on an element in the browser. Thanks to [@David-Moreira](https://github.com/David-Moreira) for the help troubleshooting this issue. By [@egil](https://github.com/egil).

- `FocusAsync()` method handler on `ElementReference` and `<FocusOnNavigate>` js handler return completed `Task`. By [@anddrzejb](https://github.com/anddrzejb).

## [1.2.49] - 2021-08-09

### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#if NET5_0_OR_GREATER
using System;
using Microsoft.AspNetCore.Components;
Expand All @@ -21,7 +22,9 @@ internal sealed class FocusAsyncInvocationHandler : JSRuntimeInvocationHandler
/// </summary>
internal FocusAsyncInvocationHandler()
: base(inv => inv.Identifier.Equals(FocusIdentifier, StringComparison.Ordinal), isCatchAllHandler: false)
{ }
{
SetVoidResult();
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ internal sealed class FocusOnNavigateHandler : JSRuntimeInvocationHandler
/// </summary>
internal FocusOnNavigateHandler()
: base(inv => inv.Identifier.Equals(Identifier, StringComparison.Ordinal), isCatchAllHandler: true)
{ }
{
SetVoidResult();
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,23 @@ public void Test002()
invocations[1].Arguments[0].ShouldBeElementReferenceTo(inputs[1]);
}

[Fact(DisplayName = "Will return completed task")]
public void Test003()
{
var cut = RenderComponent<FocusingComponent>();
Assert.True(cut.Instance.AfterFirstRender);
}

private class FocusingComponent : ComponentBase
{
private ElementReference elmRef;
internal bool AfterFirstRender { get; private set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await elmRef.FocusAsync();
AfterFirstRender = true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@ public void Test001()
.Arguments[0]
.ShouldBe(focusOnNavigateComponent.Instance.Selector);
}

[Fact(DisplayName = "Will return completed task")]
public void Test002()
{
var cut = RenderComponent<App>(ps => ps
.Add<FocusOnNavigateInternal, RouteData>(p => p.FoundTemplate, routeData => cps => cps
.Add(x => x.RouteData, routeData)
.Add(x => x.Selector, "h1")));

var focusOnNavigateComponent = cut.FindComponent<FocusOnNavigateInternal>();
Assert.True(focusOnNavigateComponent.Instance.AfterFirstRender);
}

private class FocusOnNavigateInternal : FocusOnNavigate
{
internal bool AfterFirstRender { get; private set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
{
AfterFirstRender = true;
}
}
}
}
}
#endif