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

The helperContainer callback should provide the this context #536

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Tofandel
Copy link

@Tofandel Tofandel commented May 5, 2019

If I want to append the sorted element within the element that is being sorted and not to the body (to not lose styling because there is a lot of css rules)
I need to pass helperContainer: function() { return this.container } as a prop, but the this is not passed as a context to the function so it doesn't work, replacing the function call by .call(this) effectively addresses the issue (another possibility is to just send the this attribute to the function, whichever is prefered)

I was also wondering why append the element to the body and not to the container by default? It would prevent a lot of issues like having to add a z-index to the element, having css rules you don't have power on that don't apply because the element is not nested within it's previous selectors, also prevents invalid html (If I have a <li> as a SortableItem, the <li> is directly appended to the body and that's not valid html, since it should be in an <ul>, having it in the original container also fixes this issue)

It would be a breaking change though since now people may rely on styling the element within the body although it should be minimal.

The .call(this) though is not a BC so feel free to make a release with only the first change and then a version bump with the second one

If I want to append the sorted element within the element that is being sorted (to not lose styling because there is a lot of css rules)
I need to pass helperContainer: () => { return this.container } as a prop, but the this is not passed as a context to the function so it doesn't work, adding .call(this) effectively addresses the issue

I was also wondering why append the element to the body and not to the container by default? It would prevent a lot of issues
@pjshy
Copy link

pjshy commented May 7, 2019

I think the helperContainer callback provide the cloned sortable helper is useful sometime. But the context is complex.

@Tofandel
Copy link
Author

@clauderic Any motion/thoughts on the PR please? It's been pending for quite some time

@Robin-Hoodie
Copy link

I was also wondering why append the element to the body and not to the container by default?

I was wondering the same thing. I imagine a lot of consumers of this library will need to work around this for the reasons you mentioned. Why not attach it to a more sensible default element or at least provide a simple option to attach it to the sortable container element?

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

Successfully merging this pull request may close these issues.

3 participants