Blazor-Diagrams / Blazor.Diagrams

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

3.0.0 beta PortRenderer ports incorrectly rendering positions when locked #242

Closed 240026763 closed 1 year ago

240026763 commented 1 year ago

The port renderer seems to be misaligning the ports when the node and ports are locked for version 3.0.0-beta2. This bug wasn't in v2.1.6. I discovered this when I have my application lock all the nodes and links. I have the port renderer not render the port if it is locked and doesn't have any links.

Code for a custom node widget

    @foreach (var port in Node.Ports)
    {
        if (Node.Locked && !port.Links.Any()) continue;
        <PortRenderer Port="port"></PortRenderer>
    }

Expected Behavior (2.1.6): Branch showing this behavior: https://github.com/240026763/Blazor.Diagrams/tree/ShowOnlyPortsWithLinks-2.1.6 image

Bugged Behavior (3.0.0): Branch showing this behavior: https://github.com/240026763/Blazor.Diagrams/tree/ShowOnlyPortsWithLinks-3.0.0Beta2 image

The behavior only gets worse the more the Node.Locked is toggled. Couldn't reproduce. Looks to persist the same issue each toggle.

zHaytam commented 1 year ago

Please try:

<PortRenderer @key="port" Port="port"></PortRenderer>

I think this issue is the same as https://github.com/Blazor-Diagrams/Blazor.Diagrams/issues/220, Blazor just doesn't pick up the changes correctly since it's a for loop.

240026763 commented 1 year ago

Indeed adding @key ="port" fixes the rendering problem when locking the nodes.