Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FluentSortableList demo is failing with error "Sortable is not defined" #2033

Closed
CurtBid opened this issue May 10, 2024 · 1 comment
Closed
Labels
triage New issue. Needs to be looked at

Comments

@CurtBid
Copy link

CurtBid commented May 10, 2024

🐛 Bug Report

FluentSortableList demo is failing with error "Sortable is not defined".

💻 Repro or Code Sample

@page "/Test2"
@rendermode InteractiveServer

@context.Name

@code {

public class Item
{
    public int Id { get; set; }
    public string Name { get; set; } = "";

    public bool Disabled { get; set; } = false;
}

public List<Item> items = Enumerable.Range(1, 10).Select(i => new Item { Id = i, Name = $"Item {i}" }).ToList();


private void SortList(FluentSortableListEventArgs args)
{
    if (args is null || args.OldIndex == args.NewIndex)
    {
        return;
    }

    var oldIndex = args.OldIndex;
    var newIndex = args.NewIndex;

    var items = this.items;
    var itemToMove = items[oldIndex];
    items.RemoveAt(oldIndex);

    if (newIndex < items.Count)
    {
        items.Insert(newIndex, itemToMove);
    }
    else
    {
        items.Add(itemToMove);
    }
}

}

🤔 Expected Behavior

A page with a sortable list.

😯 Current Behavior

Get the following error in the browser:

[2024-05-10T15:44:12.000Z] Error: Microsoft.JSInterop.JSException: Sortable is not defined
ReferenceError: Sortable is not defined
at Module.init (https://localhost:7253/_content/Microsoft.FluentUI.AspNetCore.Components/Components/SortableList/FluentSortableList.razor.js:2:5)
at https://localhost:7253/_framework/blazor.web.js:1:3244
at new Promise ()
at y.beginInvokeJSFromDotNet (https://localhost:7253/_framework/blazor.web.js:1:3201)
at fn._invokeClientMethod (https://localhost:7253/_framework/blazor.web.js:1:62914)
at fn.processIncomingData (https://localhost:7253/_framework/blazor.web.js:1:60389)
at connection.onreceive (https://localhost:7253/_framework/blazor.web.js:1:54030)
at i.onmessage (https://localhost:7253/_framework/blazor.web.js:1:82175)
at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
at Microsoft.FluentUI.AspNetCore.Components.FluentSortableList`1.OnAfterRenderAsync(Boolean firstRender) in /
/src/Core/Components/SortableList/FluentSortableList.razor.cs:line 105
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

💁 Possible Solution

🔦 Context

I am trying to add a two list sort to my application.

🌍 Your Environment

Windows
Google Chrome
.net 8.0.4
Flueint UI Blazor Library 4.7.2

@microsoft-github-policy-service microsoft-github-policy-service bot added the triage New issue. Needs to be looked at label May 10, 2024
@CurtBid
Copy link
Author

CurtBid commented May 10, 2024

Just realized I did not add in <script src="https://cdn.jsdelivr.net/npm/sortablejs@1.13.0/Sortable.min.js"></script> to my App.razor.

@CurtBid CurtBid closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New issue. Needs to be looked at
Projects
None yet
Development

No branches or pull requests

1 participant