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.52k stars 786 forks source link

Microsoft.JSInterop.JSException: Could not find 'Radzen.createEditor' ('Radzen' was undefined). #1671

Closed vpetit-reimagine closed 1 month ago

vpetit-reimagine commented 1 month ago

Describe the bug There is a consistent issue with the RadzenHtmlEditor that could be related to the fact the editor is created dynamically(?).

The script it added like the following in the App.razor before the Blazor library.

<script src="@($"_content/Radzen.Blazor/Radzen.Blazor.js?v={(typeof(Radzen.Colors).Assembly.GetName().Version)}")"></script>

If we refresh the cache of the browser, it somewhat works a bit but it is not reliable as it always break again after some point (whenever we do a change on the page that is unrelated to anything Radzen touches upon).

Even tho the exception is thrown, the editor still is created.

I don't mind the issue on a local machine during development, but it is extremely problematic when it happens on a staging or production environment.

Expected behavior The editor is created and no exception is thrown for w/e weird reason

Screenshots image

Desktop (please complete the following information):

akorchev commented 1 month ago

We need a reproduction of this issue in order to troubleshoot. You can also try moving the Radzen.Blazor.js script before blazor.web.js to see if it makes a difference.

vpetit-reimagine commented 1 month ago

We need a reproduction of this issue in order to troubleshoot. You can also try moving the Radzen.Blazor.js script before blazor.web.js to see if it makes a difference.

It is already before blazor.web.js, as mentioned previously and as shown here: image

It will be difficult to provide you with a reproduction of it, I will see what can be done on that

akorchev commented 1 month ago

I am afraid that without a reproduction we can't do much. It seems that Blazor tries to initialise before the Radzen.Blazor.js file has been loaded (or it failed to load/parse it). In any case you can check your browser developer tools for any errors that may have occurred before that - for example a 404 error for Radzen.Blazor.js , a parse error etc.

vpetit-reimagine commented 1 month ago

I am afraid that without a reproduction we can't do much. It seems that Blazor tries to initialise before the Radzen.Blazor.js file has been loaded (or it failed to load/parse it). In any case you can check your browser developer tools for any errors that may have occurred before that - for example a 404 error for Radzen.Blazor.js , a parse error etc.

When reading your reply here, I looked at the console and saw that indeed, even if Radzen is loaded correctly, any JS error that is triggered (and not catched) breaks Radzen. I wonder if that could be something that is mentioned on the documentation in a "troubleshooting common issues". I didn't see it anywhere, which could potentially prevent most reported issues.

I am not yet 100% convinced that this solves everything, but with my limited tests, catching all possible errors as they occur does seem to solve the behavior that I experienced

akorchev commented 1 month ago

Indeed JavaScript errors usually prevent other scripts from running correctly which isn't specific to Radzen (this is why we haven't documented it).