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

Support for nested sortable-group items. #359

Open
alexabreu opened this issue Feb 18, 2020 · 3 comments
Open

Support for nested sortable-group items. #359

alexabreu opened this issue Feb 18, 2020 · 3 comments

Comments

@alexabreu
Copy link
Contributor

I've run into a few issues when using ember-sortable with nested groups. My original approach assumed a child sortable-group onChange handler would be responsible for sorting child items. Unfortunately, it seems these change events bubble up to the handler for parent items. Once I realized that to be the case, I was able to work around the issue, by filtering out items accordingly by inspecting the draggedItem argument in the parent onChange callback. Would it be possible to scope change handlers to only worry about changes to direct sortable-item children? I believe this would make working with nested draggable lists a bit easier.

The second challenge I've run into is that the transitionY transform applied to items during drag seems to break down with nested sortable-groups. Despite explicitly setting spacing to 0 (though it seems this isn't required), a great deal of whitespace is inserted between all the draggable items in the tree (parent and child items). This makes for an unusable D&D experience, as it is difficult to drag an item past all the extra whitespace and still know where the item is going to be inserted relative to where it was previously.

Original Approach

<ol {{sortable-group onChange=this.handleParentItems}}>
    <li {{sortable-item model=parentItem}}>
        <ol {{sortable-group onChange=this.handleChildItems}}>
            <li {{sortable-item model=childItem}}/>
        </ol>
   </li>
</ol>

Screenshots

In this example, each category (i.e. Cherry, Apple, Peach) should be draggable to allow sorting of categories. In addition, each item within a category should also be draggable to allow sorting of those items (i.e. Cherry, Cherry With Fruit).

image

@ygongdev
Copy link
Member

ygongdev commented Jan 8, 2021

For the 1st scenario, I believe you can solve the problem by adding explicit groupName on each sortable-group

@dirkdirk
Copy link

dirkdirk commented May 5, 2021

Working with <div>s:

Screen Shot 2021-05-05 at 11 13 58 AM

@NullVoxPopuli
Copy link
Contributor

Anyone want to PR one of these nested lists to the docs?

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

4 participants