thisbeyond / solid-dnd

A lightweight, performant, extensible drag and drop toolkit for Solid JS.
https://solid-dnd.com
MIT License
505 stars 35 forks source link

Fixed the children prop for DragOverlay #93

Closed pardeshirzadeh closed 10 months ago

pardeshirzadeh commented 1 year ago

DragOverlay is currently defined as ParentComponent<DragOverlayProps>, but it doesn't work in the following scenario in a .tsx file:

<DragOverlay>
  {(draggable) => <div>Drag overlay for {draggable?.id}</div>}
</DragOverlay>

It will throw the following error

Type '(draggable: Draggable$1 | null) => Element' is not assignable to type '((number | boolean | Node | ArrayElement | (string & {}) | ((activeDraggable: Draggable$1 | null) => Element)) & (number | boolean | Node | ArrayElement | (string & {}))) | null | undefined'.
  Type '(draggable: Draggable$1 | null) => Element' is not assignable to type '((activeDraggable: Draggable$1 | null) => Element) & number'.
    Type '(draggable: Draggable$1 | null) => Element' is not assignable to type 'number'.

The reason for that is because ParentComponent overrides children, so the definition in DragOverlayProps is ignored.

martinpengellyphillips commented 1 year ago

Hmm, I don't understand. What does "not work" mean here?

pardeshirzadeh commented 1 year ago

I updated the first comment with more details. Hope it's more clear now

Adevien commented 10 months ago

This is still a current issue on latest version. Any updates?

martinpengellyphillips commented 10 months ago

Ah yes, I was just looking at this. I think we should use Component here still to maintain return type etc.

malekim commented 10 months ago

Unfortunately, it didn't solve the issue.


TS2322: Type '(draggable: Draggable$1 | null) => Element' is not assignable to type '((number | boolean | Node | ArrayElement | (string & {}) | ((activeDraggable: Draggable$1 | null) => Element)) & (number | boolean | Node | ArrayElement | (string & {}))) | null | undefined'.   Type '(draggable: Draggable$1 | null) => Element' is not assignable to type '((activeDraggable: Draggable$1 | null) => Element) & number'.     Type '(draggable: Draggable$1 | null) => Element' is not assignable to type 'number'.`
Adevien commented 10 months ago

took latest commit, it did solved the issue as far as I can tell :)

martinpengellyphillips commented 10 months ago

Thanks @Adevien - @malekim I wonder why not working for you 🤔