Skip to content

Sorting breaking when using blazor components in SortableItemTemplate #12

@DavidGabelgaard

Description

@DavidGabelgaard

Problem:
The revering back in onUpdate uses index of the items, however since blazor adds a comment like this ( ) between its componenets as markers for its internal rendering logic using index no longer works

Solution: in the js file create a function to filter out the comments:
function filterCommentNodes(nodes) {
return Array.from(nodes).filter(node => node.nodeType !== Node.COMMENT_NODE);
}
and use that like normal
event.to.insertBefore(event.item, filterCommentNodes(event.to.childNodes)[event.oldIndex]);

Thanks for an awsome project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions