Working on a Blazor WASM app (.NET 8) and seeing the error below in the browser's console after successful Hot Reload from VS2022 and clicking on any button in the app. Same button works fine before the Hot Reload. The issue is not limited only to buttons. I believe this started with the latest VS update (17.10.3). The Telerik version we're using is old, 4.3.0, however we never had that particular issue before.
Anybody having the same issues? Is this VS issue?
Thank you,
Stefan
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'addEventListener')
TypeError: Cannot read properties of null (reading 'addEventListener')
at gD.bindEvents (http://localhost:5137/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1844171)
at gD.onAfterShow (http://localhost:5137/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1844381)
at Module.fe (http://localhost:5137/_content/Telerik.UI.for.Blazor/js/telerik-blazor.js:50:1044593)
at http://localhost:5137/_framework/blazor.webassembly.js:1:2878
at new Promise (<anonymous>)
at b.beginInvokeJSFromDotNet (http://localhost:5137/_framework/blazor.webassembly.js:1:2835)
at Object.vn [as invokeJSJson] (http://localhost:5137/_framework/blazor.webassembly.js:1:58849)
at http://localhost:5137/_framework/dotnet.runtime.8.0.5.gongq8hbow.js:3:178364
at Tl (http://localhost:5137/_framework/dotnet.runtime.8.0.5.gongq8hbow.js:3:179198)
at wasm://wasm/00b2193a:wasm-function[349]:0x1fab4
at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
at Telerik.Blazor.Components.Dialog.DialogBase.InvokeOnAfterShowAsync()
at Telerik.Blazor.Components.Dialog.DialogBuilder.OnAfterRenderAsync(Boolean firstRender)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Additional info. The issue is caused by Dialogs.AlertAsync.
Steps to reproduce. Start with the default Blazor WASM project template. Add the Telerik to it. Then change the Counter.razor as shown below. Start debugging. Everything works fine. Change the button text from 'Click me' to 'Click me 2'. Hot Reload. On the button click the 5 seconds delay works fine but the error shows as soon as Alert Async is called. Calling the method in more async fashion @onclick="@(async Task() => await IncrementCount())" doesn't help. Making the method synchronous doesn't help either.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<h1>Counter</h1><p role="status">Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
@code {
[CascadingParameter] public required DialogFactory Dialogs { get; set; }
private int currentCount = 0;
private async Task IncrementCount()
{
currentCount++;
Console.WriteLine("Delay for 5sec.");
await Task.Delay(5000);
Console.WriteLine("Show alert.");
await Dialogs.AlertAsync($"Clicked");
}
}