Skip to content

Incorrect type definition provided for nodes argument in onSortEnd prop #885

Description

@smtchahal

According to the type definition, nodes of onSortEnd is an array of HTMLElement:

export interface SortEnd {
oldIndex: number;
newIndex: number;
collection: Offset;
isKeySorting: boolean;
nodes: HTMLElement[];
}

But in reality, to access the HTMLElement, you need to use nodes[0].node, which triggers TypeScript error:

<MySortableList
    // ...
    onSortEnd={({ oldIndex, newIndex, nodes }) => {
        console.log('nodes are', nodes); // {boundingClientRect: null, edgeOffset: null, node: HTMLElement, translate: null}[]
    
        const node = nodes[0].node
        console.log('the actual HTML element is', node);
    }}
    // ...
/>

So it looks like either the typedef is wrong, or the code is wrong.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions