-
Notifications
You must be signed in to change notification settings - Fork 58
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
Error in ContextMenuTrigger AfterRenderAsync on iOS #80
Comments
This seems really weird. I don't have any iOS devices and I have not used this "Handoff" feature. Could you please reference the unminified "_content/Blazor.ContextMenu/blazorContextMenu.js" in your code instead of the minified version and post the error again? Maybe I can guess why the error is happening if I can see where it throws on the unminified code. Also is the error occuring when opening a context menu or just by loading the page? |
Thanks for the quick reply! I will indeed switch to the unminified script file and see what we can get. It is definitely a very bizarre set of circumstances that seem to be causing it. It takes a bit of work to reproduce and capture the error and we only have one Mac in the organization, so I'll have a co-worker do this tomorrow. As far as your other question, it crashes the app simply by loading the page. However, as indicated, it doesn't "break" until you open the same page on another Apple device, then it breaks for phones only. Once it's "broken" too, it's broken. The context menu is on the detail lines of a grid. The only way to "fix" the broken page for a phone is to delete all the lines from the grid. |
OK, we were able to reproduce the error again, this time using the unminified script. Error: Microsoft.JSInterop.JSException: null is not an object (evaluating 'triggerElement.dataset') |
The triggerElement was not captured correctly by the blazor framework to be passed down to javascript. This is really really weird. I am starting to think that this is a blazor server side issue, because there is no way that the triggerElement would be null at that point. Something is probably getting blazor confused on what is rendered etc. I deduce I think further investigation is required, probably something that we have to reproduce for the blazor team. Can you please try to reproduce by creating 2 new projects, one blazor server and one in blazor wasm and then do the following
@inject IJSRuntime jsRuntime
@page "/"
<h1 @ref="h1" data-value="some data">Hello, world!</h1>
@if(data != null)
{
<p>Data from interop: @data</p>
}
@code{
ElementReference h1;
string data;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
data = await jsRuntime.InvokeAsync<string>("GetData", h1);
Console.WriteLine($"Read data from element: {data}");
StateHasChanged();
}
}
}
<script>
GetData = function (element) {
return element.dataset["value"];
}
</script>
|
We've created the requested projects and there does not appear to be any errors (i.e. we're unable to "break" it) after opening it on a phone, then a different device, then the phone again. In all cases, the page renders and correctly displays the "Data from interop: some data". |
I'm seeing the same issue - running a Blazor server app on Linux, and accessing it via MacOS, so I'm interested to know what the resolution might be. |
Did you ever get to the bottom of this? |
No sorry. I just don't have the means to reproduce it. Maybe cloning the repo and adding the contextmenu as a project reference instead of a nuget package will help use locate the problem |
Hi, thanks for a cool package! I'm having a similar issue in a wasm project, using .NET6, and BlazorContextMenu 1.10.0 in both Chrome/Windows and Safari/iOS. It always happen at a very specific point in time, and can only be replicated at that time. I use it for a user-menu, meaning it's only available for signed in users. I'm using built-in asp.net identity, and the menu resides within a The issue goes away if I place the Error
DebugCode<AuthorizeView Context="authContext">
<Authorized>
<ContextMenu Id="userMenu" Animation="Animation.FadeIn">
<Item>@authContext?.User?.Identity?.Name</Item>
<Seperator />
<Item OnClick="BeginSignOut">@Loc["Log out"]</Item>
</ContextMenu>
<ContextMenuTrigger MenuId="userMenu" MouseButtonTrigger="MouseButtonTrigger.Both">
<button class="btn btn-avatar">
<i class="bi bi-person-circle text-secondary"></i>
</button>
</ContextMenuTrigger>
</Authorized>
<NotAuthorized>
...
</NotAuthorized>
</AuthorizeView> |
Thank you for the reproduction steps. Blazor in .net 6 supports some new was to initialize startup code so that might help but I will have to refactor the JS part of the lib to a module for that to work. |
Added some guards attempting to fix #80
Is it fixed? Nice!! Great demonstration of how a decent repro makes a fix easy. Thanks to @MichelJansson for creating it. |
Can you please use version 1.10.1 to see if it is fixed for you ? |
I removed BlazorContextMenu and replaced it with Radzen temporarily until this issue was fixed; I'll have to add your project back into mine and test it, so it won't be something I can do for a couple of days. |
That was fast - thanks!
After a quick test, it seems to work, no more exception! I'll test it more thoroughly later this week. |
Nice, I will close this issue then. Please reopen it if you find some problem |
We have been experiencing an issue on a page that uses Blazor Context Menu. If a user opens the page on linked Apple Devices (i.e. an iPad) and then opens the same page on an iPhone, the app crashes. It seems it could be related to "handoff" somehow, be we aren't entirely certain. After enabling detailed errors and hooking a phone up to a mac to gain access to a Safari developer console, we were able to see the actual error that was occurring....
Error: Microsoft.JSInterop.JSException: null is not an object (evaluating 'e.dataset')
_content/Blazor.ContextMenu/blazorContextMenu.min.js:1:3553
[native code]
_framework/Blazor.ContextMenu/blazor.server.js:8:31426
Promise@[native code]
beginInvokeJSFromDotNet@_framework/Blazor.ContextMenu/blazor.server.js:8:31401
forEach@[native code]
_framework/Blazor.ContextMenu/blazor.server.js:1:19180
_framework/Blazor.ContextMenu/blazor.server.js:1:17183
_framework/Blazor.ContextMenu/blazor.server.js:1:38100
at Microsoft.JSInterop.JSRuntime.InvokeWithDefaultCancellation[T](String identifier, Object[] args)
at BlazorContextMenu.ContextMenuTrigger.OnAfterRenderAsync(Boolean firstRender)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
Error: Circuit has been shut down due to error.
After I remove the Context Menu from the page, the error is unable to be reproduced.
It's obviously a bit of a perfect storm and very difficult to provide a reproduction as it only seems to happen after opening the page on multiple iOS devices and then only on the phone. I'm hoping maybe the error itself may provide a clue as to what's going on or a potential fix?
The text was updated successfully, but these errors were encountered: