From a73d87797739df76218a82d4ace9182aa85d0e1e Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Thu, 13 Jun 2019 19:10:05 +0300 Subject: [PATCH 1/2] hack/fix for https://github.com/aspnet/AspNetCore/issues/11159 --- .../Components/ContextMenuTrigger.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/BlazorContextMenu/Components/ContextMenuTrigger.cs b/BlazorContextMenu/Components/ContextMenuTrigger.cs index 844b18a..867a45e 100644 --- a/BlazorContextMenu/Components/ContextMenuTrigger.cs +++ b/BlazorContextMenu/Components/ContextMenuTrigger.cs @@ -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 CreateDotNetObjectRef(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("blazorContextMenu.SetMenuHandlerReference", DotNetObjectRef.Create(blazorContextMenuHandler)); + await jsRuntime.InvokeAsync("blazorContextMenu.SetMenuHandlerReference", CreateDotNetObjectRef(blazorContextMenuHandler)); blazorContextMenuHandler.ReferencePassedToJs = true; } } From 46bbede7b0d3d9fa2eb1996d49b5e3eced5ce756 Mon Sep 17 00:00:00 2001 From: stavroskasidis Date: Thu, 13 Jun 2019 19:12:56 +0300 Subject: [PATCH 2/2] version bump --- BlazorContextMenu/BlazorContextMenu.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BlazorContextMenu/BlazorContextMenu.csproj b/BlazorContextMenu/BlazorContextMenu.csproj index 903c2dd..e6e8ac2 100644 --- a/BlazorContextMenu/BlazorContextMenu.csproj +++ b/BlazorContextMenu/BlazorContextMenu.csproj @@ -19,7 +19,7 @@ blazor blazor-component blazor-context-menu context-menu contextmenu menu blazor-menu blazorcontextmenu razor razor-components razorcomponents $(VersionSuffix) - 0.16.0 + 0.16.1 $(Version)-$(VersionSuffix) Blazor.ContextMenu