Blazor-Diagrams / Blazor.Diagrams

A fully customizable and extensible all-purpose diagrams library for Blazor
https://blazor-diagrams.zhaytam.com
MIT License
921 stars 177 forks source link

.NET6 Blazor Server zoom issue #224

Closed deborggraever closed 1 year ago

deborggraever commented 1 year ago

Package version: 2.1.6 Application: Blazor Server Framework: net6

We have implemented Blazor.Diagrams in a .NET6 Blazor server project to create a workflow editor. Everything works fine, except scrolling.

While we zoom in or out, sometime we get an exception, resulting the website to stop working. An unhandled exception has occurred. See browser dev tools for details. [Reload](http://localhost:5100/dev/)

It seems to happen randomly, sometime when zoom in, sometime when zoom out and at random zoom levels. When looking at the dev console of the browser we see the following error:

blazor.server.js:1 [2022-08-31T12:02:15.483Z] Error: Microsoft.JSInterop.JSException: Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element'.
TypeError: Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element'.
    at Object.unobserve (http://localhost:5100/dev/_content/Z.Blazor.Diagrams/script.min.js:1:747)
    at http://localhost:5100/dev/_framework/blazor.server.js:1:3501
    at new Promise (<anonymous>)
    at kt.beginInvokeJSFromDotNet (http://localhost:5100/dev/_framework/blazor.server.js:1:3475)
    at http://localhost:5100/dev/_framework/blazor.server.js:1:72054
    at Array.forEach (<anonymous>)
    at kt._invokeClientMethod (http://localhost:5100/dev/_framework/blazor.server.js:1:72040)
    at kt._processIncomingData (http://localhost:5100/dev/_framework/blazor.server.js:1:70082)
    at connection.onreceive (http://localhost:5100/dev/_framework/blazor.server.js:1:64485)
    at o.onmessage (http://localhost:5100/dev/_framework/blazor.server.js:1:48819)
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args)
   at Blazor.Diagrams.Extensions.JSRuntimeExtensions.UnobserveResizes(IJSRuntime jsRuntime, ElementReference element)
   at Blazor.Diagrams.Components.Renderers.NodeRenderer.CheckVisibility()
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteSynchronously(TaskCompletionSource`1 completion, SendOrPostCallback d, Object state)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c.<.cctor>b__23_0(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.ExecuteBackground(WorkItem item)
zHaytam commented 1 year ago

Related to #155 Please set EnableVirtualization to false, this has been fixed in 3.0 (currently being developped).

deborggraever commented 1 year ago

This solved the problem, thanks.

zHaytam commented 1 year ago

Glad it did! Closing this as the other issue already tracks it.