Giter VIP home page Giter VIP logo

Comments (4)

Postlagerkarte avatar Postlagerkarte commented on July 27, 2024

Hi @AnaStepic - thanks for bringing this to my attention.

Are you able to reproduce this in a minimalstic project that you can provide me for debugging?

from blazor-dragdrop.

AnaStepic avatar AnaStepic commented on July 27, 2024

Yes. I just created a new Blazor project in Visual Studio and installed Drag & Drop.

I edited Index.razor and created two components: MyComponent & Card

If you run the program, you'll see these two cards:
image

Both the left and right cards have the exact same code. The only difference is that in the left card, that code is placed in MyComponent.razor, while in the right case, the code is pasted in the Index.razor

If you click on "Click me to toggle state", the text below should change. And it does, on the right card, but not on the left. If you put a breakpoint in the code, you'll see that the click method does get called, but the rendering of the card isn't updated. It won't update even if you call StateHasChanged()

Index.razor:

@page "/"

<div class="row">
    <div class="col">
        <Dropzone Class="row" Name="Column1">
            <MyComponent />
        </Dropzone>

    </div>
    <div class="col">
        <Dropzone Class="row" Name="Column2">
            <Card Title="Card">
                <a @onclick="Clicked">Click Me To Toggle State</a>

                @if (_toggle)
                {
                    <p class="text-danger">I have been toggled</p>
                }
                else
                {
                    <p class="text-primary">I have not yet been toggled</p>
                }
            </Card>
        </Dropzone>
    </div>
</div>
@code{
    bool _toggle = true;

    void Clicked()
    {
        _toggle = !_toggle;
    }
}

MyComponent:

<Card Title="My Component">
    <a @onclick="Clicked">Click Me To Toggle State</a>

    @if (_toggle)
    {
        <p class="text-danger">I have been toggled</p>
    }
    else
    {
        <p class="text-primary">I have not yet been toggled</p>
    }
</Card>

@code {
    bool _toggle = true;

    void Clicked()
    {
        _toggle = !_toggle;
    }
}

Card:

<Draggable AllOtherAttributes="@_attributes" Name="@Title">
    <div class="card shadow mb-2">
        <div class="card-header">
            <h6 class="m-0 font-weight-bold @TitleColor">@Title</h6>
        </div>
        <div class="card-body">
            @ChildContent
        </div>
    </div>
</Draggable>
@code {
            [Parameter]
            public string TitleColor { get; set; } = "text-primary";
            [Parameter]
            public string Title { get; set; }

            [Parameter] public RenderFragment ChildContent { get; set; }

            Dictionary<string, object> _attributes => new Dictionary<string, object>() { { "class", "col-12 dashboard-card" } };
}

The VS solution:
Test.zip

from blazor-dragdrop.

Postlagerkarte avatar Postlagerkarte commented on July 27, 2024

@AnaStepic I can reproduce the error.

If you change your code to

           <Draggable>
                <MyComponent />
            </Draggable>

(and remove the draggable from the card component)

you can fix the issue.

Unfortunately, there is no short-term fix to make it work otherwise.

from blazor-dragdrop.

AnaStepic avatar AnaStepic commented on July 27, 2024

I see. So have to avoid putting draggable further down in the component hierarchy and figure out a way around it if needed.

from blazor-dragdrop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.