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

Strange behavior of 'maxItems' property #713

Closed
r34117y opened this issue Apr 8, 2021 · 2 comments · Fixed by #761
Closed

Strange behavior of 'maxItems' property #713

r34117y opened this issue Apr 8, 2021 · 2 comments · Fixed by #761

Comments

@r34117y
Copy link

r34117y commented Apr 8, 2021

When I initialize my sortable with maxItems : 1 the container doesn't allow to drop any items.

With maxItems : 2 it allows to drop one item. The container is empty (no hidden elements, nothing).

I think that placeholder element is counted, but that would be very counter-intuitive.

Anouther possible cause is that I initialize many containers at once (each table cell is a drop container).

Code:

sortable('td.label', {
            acceptFrom : '.unused, .label',
            maxItems : 2, // allows one item to be dropped
            placeholderClass: 'list-group-item',
            dropTargetContainerClass: 'bg-destroy'
        })
@lukasoppermann
Copy link
Owner

Hey @r34117y that is definitely not expected.

Would you be able to investigate the issue and maybe send a PR to fix it?

The issue could possibly be here: https://github.com/lukasoppermann/html5sortable/blob/master/src/html5sortable.ts#L632
If the idea you suggested is true we would need to replace sortableElement.children with a function may getSortableChildren(sortableElement). This would probably need to be used everywhere, where sortableElement.children is used now.

But to beging with you could add the function and replace this one instance to fix this specific bug.

lukasoppermann added a commit that referenced this issue Jun 15, 2021
lukasoppermann added a commit that referenced this issue Jun 15, 2021
@lukasoppermann
Copy link
Owner

Hey @r34117y this should be fixed now. Let me know if it works.

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

Successfully merging a pull request may close this issue.

2 participants