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

The MudBlazor menu appears in the top left corner of the container when right clicking on a node component #321

Closed mrakgr closed 1 year ago

mrakgr commented 1 year ago

I have a MudBlazor menu that is using DiagramCanvas as an activation context which gets triggered on a right click. This works fine when I click on an empty space on a canvas and I've even made it so that I can add nodes using that opened menu. But when I right click on a node, the menu doesn't appear at cursor, but in top left corner instead. Maybe it is getting passed null as the position? Would it be possible to fix that?

Ideally, I'd like to suppress its activation when clicking on a node, but maybe I'd need to implement a different kind of system for that.

mrakgr commented 1 year ago
<MudCard Class="pa-8 ma-0" Style="width: 300px;" 
         @oncontextmenu:stopPropagation>
    <MudTextField T="string"
                  DisableUnderLine="true"
                  Variant="Variant.Outlined" Lines="5"
                  @bind-Value="@Node.Text"
                  @onmousedown:stopPropagation @onmousemove:stopPropagation
    />
    @foreach (var port in Node.Ports)
    {
        <PortRenderer Port="port"/>
    }
</MudCard>

Suppressing it like this is good enough for the time being, though I am wondering if it would be possible to fix the positioning issue.

zHaytam commented 1 year ago

Hey, glad you figured it out. It is necessary to stop the propagation of events from other controls in order to stop these unwanted behaviors (since events travel from child to parent).

Can you create another issue for the positioning?