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

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

Open
smtchahal opened this issue Jan 7, 2025 · 0 comments
Open

Comments

@smtchahal
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant