serdarciplak / BlazorMonaco

Blazor component for Microsoft's Monaco Editor which powers Visual Studio Code.
https://serdarciplak.github.io/BlazorMonaco/
MIT License
432 stars 98 forks source link

Sometimes not initialized correctly #126

Open MeikelLP opened 4 months ago

MeikelLP commented 4 months ago

I'm pretty new to Blazor and am not that good at debugging.

I'm running in rendermode InteractiveServer (otherwise its not working at all).

obaki102 commented 3 months ago

I found a workaround. It seems that if you set your render mode on a per-component basis, the necessary JavaScript script files from Monaco are not loaded properly when establishing a web socket connection or when downloading the DLL in WebAssembly mode. That's why you notice a delay and sometimes a full page reload is needed for the text editor to work.

So, in order for it to work, you need to establish a WebSocket connection readily when accessing the page. This can be achieved by setting the render mode globally. In this case, I choose 'InteractiveAuto' and add it to the Routes in the App.razor page.

<Routes @rendermode="InteractiveAuto" />

Finally, I moved all my pages that needs interactivity into the client project, including my layout, and the Routes.razor page.

image

For more info you can check

I believe one drawback of this approach is being limited to 'auto' mode, thus unable to utilize Server-Side Rendering (SSR).

SSzretter commented 2 months ago

I have this same issue, vs 2002 .net8 webapp project. I using Syncfusion so not sure if that is causing an issue but it looks just like the picture in the first post and when I refresh the width corrects but not the height (I have the stock navigation on the left of the page). To get the height corrected, I had to do this (I couldnt get the css to apply otherwise for some reason):

<StandaloneCodeEditor Id="monaco-editor-instance-id" ConstructionOptions="EditorConstructionOptions" CssClass="min-vh-100" />

When I navigate to the page:

image

If I click refresh on that page: image

Seems like when the page refreshes its calculating something differently.

First page load:

image

Refresh of page: image