Skip to content

Sortable: Pass this to _uiHash() when firing 'remove' events. Fixes #9738: Remove event object doesn't contain sender when moving an item between connected sortables. #1171

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions tests/unit/sortable/sortable_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,36 @@ test("#4752: link event firing on sortable with connect list", function () {
test("receive", function() {
ok(false, "missing test - untested code is broken code.");
});
*/

test("remove", function() {
ok(false, "missing test - untested code is broken code.");
expect( 8 );

var hash,
removeCount = 0,
item = $( "#sortable" ).find( "li:last" );

$( ".connectWith" ).sortable({
connectWith: ".connectWith",
remove: function( e, ui ) {
hash = ui;
removeCount++;
}
});

item.simulate( "drag", {
dy: 40
});

ok( hash, "remove event triggered" );
ok( !hash.helper, "UI should not include: helper" );
ok( hash.placeholder, "UI hash includes: placeholder" );
ok( hash.position && ( "top" in hash.position && "left" in hash.position ), "UI hash includes: position" );
ok( hash.offset && ( hash.offset.top && hash.offset.left ), "UI hash includes: offset" );
equal( hash.item.html(), item.html(), "UI hash includes: item" );
equal( hash.sender.html(), $( "#sortable" ).html(), "UI hash includes: sender" );
equal( removeCount, 1, "remove fires only once" );
});
*/

test( "over", function() {
expect( 8 );
Expand Down
2 changes: 1 addition & 1 deletion ui/jquery.ui.sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ $.widget("ui.sortable", $.ui.mouse, {
// events.
if (this !== this.currentContainer) {
if(!noPropagation) {
delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash(this)); });
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
}
Expand Down