Skip to content

Commit

Permalink
fix: PortRender not taking into account it's parent's RenderLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
zHaytam committed Mar 19, 2021
1 parent 855568e commit ceeda81
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/Blazor.Diagrams/Components/LinkWidget.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Microsoft.AspNetCore.Components.Web;
using Blazor.Diagrams.Core.Geometry;
using System.Collections.Generic;
using System;

namespace Blazor.Diagrams.Components
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
using System.Threading.Tasks;
using Blazor.Diagrams.Extensions;
using Blazor.Diagrams.Core.Geometry;
using Microsoft.AspNetCore.Components.Rendering;

namespace Blazor.Diagrams.Components.Renderers
{
public partial class PortRenderer : IDisposable
public class PortRenderer : ComponentBase, IDisposable
{
private bool _shouldRender = true;
private ElementReference _element;
Expand Down Expand Up @@ -44,6 +45,20 @@ protected override void OnInitialized()

protected override bool ShouldRender() => _shouldRender;

protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.OpenElement(0, Port.Parent.Layer == RenderLayer.HTML ? "div" : "g");
builder.AddAttribute(1, "class", "port" + " " + (Port.Alignment.ToString().ToLower()) + " " + (Port.Links.Count > 0 ? "has-links" : "") + " " + (Class));
builder.AddAttribute(2, "data-port-id", Port.Id);
builder.AddAttribute(3, "onmousedown", EventCallback.Factory.Create<MouseEventArgs>(this, OnMouseDown));
builder.AddEventStopPropagationAttribute(4, "onmousedown", true);
builder.AddAttribute(5, "onmouseup", EventCallback.Factory.Create<MouseEventArgs>(this, OnMouseUp));
builder.AddEventStopPropagationAttribute(6, "onmouseup", true);
builder.AddElementReferenceCapture(7, (__value) => { _element = __value; });
builder.AddContent(8, ChildContent);
builder.CloseElement();
}

protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
Expand Down
9 changes: 0 additions & 9 deletions src/Blazor.Diagrams/Components/Renderers/PortRenderer.razor

This file was deleted.

0 comments on commit ceeda81

Please sign in to comment.