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

Why not to use slots? #2

Open
PlkMarudny opened this issue Aug 5, 2020 · 6 comments
Open

Why not to use slots? #2

PlkMarudny opened this issue Aug 5, 2020 · 6 comments

Comments

@PlkMarudny
Copy link

Why not to use slots for rendering list items?

@jwlarocque
Copy link
Owner

I didn't use slots primarily because I didn't anticipate that doing so would be useful. The original design scope of this component was simply to provide the end user a way to order a list of strings.

Additionally, this component relies on carefully controlled pointer events. Providing more opportunities for list items to be interactive also provides more opportunities for problems with the drag and drop behavior.

Anyways, please tell me more about why/how you would like to use slots - I want to make this component as useful as possible.
You are also welcome to suggest an implementation or submit a PR if you would like.

@PlkMarudny
Copy link
Author

PlkMarudny commented Aug 21, 2020

This is what I use:

image

I am passing down another component, with the input, three checkboxes, and a few labels. My component fires several events to be served by a component up in the hierarchy.
What I did at the end was changing the source of your great component to implement this. Had to disable events on the input, as I discovered some strange side effects while dragging via input element. No slots used. Initially was under impression slots would had been enough.

@nicknack23
Copy link

+1 for slots. I want to use this to make a sortable file tree, where nodes can be folders that contain other nodes. So I need full control over the "list elements" (and would scrap the up/down and delete buttons). Ergo I need slots.

@elimisteve
Copy link

@nicknack23 This fork appears to have made some of the enhancements we're looking for: https://github.com/Lindsay-Needs-Sleep/svelte-dragdroplist

@PlkMarudny
Copy link
Author

I found using svelte-sortable easier after all. You can simply pass a component to your list item, this is demonstrated here REPL.

@Kauto
Copy link

Kauto commented Nov 1, 2021

@jwlarocque +1 for slots. I would use it like the html attribute in the objects. For me it's cleaner this way to format the objects. F.e. I want use flexbox to show title of music on the left side and the duration on the right side.

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

5 participants