Skip to content

Commit

Permalink
Merge pull request #47 from stavroskasidis/release/0.16.1
Browse files Browse the repository at this point in the history
Release/0.16.1
  • Loading branch information
stavroskasidis authored Jun 13, 2019
2 parents e689734 + 46bbede commit 548a17d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion BlazorContextMenu/BlazorContextMenu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<Copyright />
<PackageTags>blazor blazor-component blazor-context-menu context-menu contextmenu menu blazor-menu blazorcontextmenu razor razor-components razorcomponents</PackageTags>
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<Version>0.16.0</Version>
<Version>0.16.1</Version>
<Version Condition=" '$(VersionSuffix)' != '' ">$(Version)-$(VersionSuffix)</Version>
<Product>Blazor.ContextMenu</Product>
</PropertyGroup>
Expand Down
16 changes: 15 additions & 1 deletion BlazorContextMenu/Components/ContextMenuTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,25 @@ protected override void OnInit()
}
}

#region Hack to fix https://github.com/aspnet/AspNetCore/issues/11159

public static object CreateDotNetObjectRefSyncObj = new object();

protected DotNetObjectRef<T> CreateDotNetObjectRef<T>(T value) where T : class
{
lock (CreateDotNetObjectRefSyncObj)
{
JSRuntime.SetCurrentJSRuntime(jsRuntime);
return DotNetObjectRef.Create(value);
}
}
#endregion

protected override async Task OnAfterRenderAsync()
{
if (!blazorContextMenuHandler.ReferencePassedToJs)
{
await jsRuntime.InvokeAsync<object>("blazorContextMenu.SetMenuHandlerReference", DotNetObjectRef.Create(blazorContextMenuHandler));
await jsRuntime.InvokeAsync<object>("blazorContextMenu.SetMenuHandlerReference", CreateDotNetObjectRef(blazorContextMenuHandler));
blazorContextMenuHandler.ReferencePassedToJs = true;
}
}
Expand Down

0 comments on commit 548a17d

Please sign in to comment.