The helperContainer callback should provide the this context #536
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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