radzenhq / radzen-blazor

Radzen Blazor is a set of 90+ free native Blazor UI components packed with DataGrid, Scheduler, Charts and robust theming including Material design and FluentUI.
https://www.radzen.com
MIT License
3.5k stars 784 forks source link

Sporadic exception 'Cannot read properties of null (reading 'innerHTML')' in HtmlEditor #449

Open OndrejUzovic opened 2 years ago

OndrejUzovic commented 2 years ago

I find the following exception in the log file of my application:

Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'innerHTML')
TypeError: Cannot read properties of null (reading 'innerHTML')
    at Object.queryCommands (https://xxx.azurewebsites.net/_content/Radzen.Blazor/Radzen.Blazor.js:1129:17)
    at https://xxx.azurewebsites.net/_framework/blazor.server.js:1:3501
    at new Promise (<anonymous>)
    at kt.beginInvokeJSFromDotNet (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:3475)
    at https://xxx.azurewebsites.net/_framework/blazor.server.js:1:72001
    at Array.forEach (<anonymous>)
    at kt._invokeClientMethod (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:71987)
    at kt._processIncomingData (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:70029)
    at vt.connection.onreceive (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:64432)
    at WebSocket.o.onmessage (https://xxx.azurewebsites.net/_framework/blazor.server.js:1:48766)
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Radzen.Blazor.RadzenHtmlEditor.UpdateCommandState()
   at Radzen.Blazor.RadzenHtmlEditor.OnFocus()
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

The exception is sporadic (several occurrences per day) and unfortunately I am not able to identify an exact use-case to reproduce it.

So I would like to ask if you have any idea what could be the problem.

OndrejUzovic commented 2 years ago

One scenario when the exception sporadically occurs is in a dialog with RadzenTabs:

  1. Open the dialog - the first Tab which contains RadzenHtmlEditor is displayed (RadzenHtmlEditor contains a text) .
  2. Click to another tab.
  3. Close the dialog.
jafin commented 3 months ago

Just started hitting this same issue as well. With RadzenHtmlEditor in Radzen.Blazor v4.33.3

If I can detect any more concrete steps I'll update my post.

Microsoft.JSInterop.JSException: Cannot read properties of null (reading 'innerHTML')
TypeError: Cannot read properties of null (reading 'innerHTML')
    at Object.innerHTML (https://localhost:7134/_content/Radzen.Blazor/Radzen.Blazor.js:1692:18)
    at https://localhost:7134/_framework/blazor.web.js:1:3244
    at new Promise (<anonymous>)
    at y.beginInvokeJSFromDotNet (https://localhost:7134/_framework/blazor.web.js:1:3201)
    at gn._invokeClientMethod (https://localhost:7134/_framework/blazor.web.js:1:62841)
    at gn._processIncomingData (https://localhost:7134/_framework/blazor.web.js:1:60316)
    at connection.onreceive (https://localhost:7134/_framework/blazor.web.js:1:53957)
    at i.onmessage (https://localhost:7134/_framework/blazor.web.js:1:82102)
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at Radzen.Blazor.RadzenHtmlEditor.OnAfterRenderAsync(Boolean firstRender)

In blazor.js image

I'm not sure if changing this to ref?.innerHTML has any side effects for callers