Skip to content

Commit e8c99b9

Browse files
committed
Draggable: Ensure sortable revert still works after draggable is removed
Fixes #9481
1 parent 27ed207 commit e8c99b9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ui/draggable.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,7 @@ $.ui.plugin.add("draggable", "connectToSortable", {
713713
var sortable = $( this ).sortable( "instance" );
714714
if (sortable && !sortable.options.disabled) {
715715
inst.sortables.push({
716-
instance: sortable,
717-
shouldRevert: sortable.options.revert
716+
instance: sortable
718717
});
719718
sortable.refreshPositions(); // Call the sortable's refreshPositions at drag start to refresh the containerCache since the sortable container cache is used in drag and needs to be up to date (this will ensure it's initialised as well as being kept in step with any changes that might have happened on the page).
720719
sortable._trigger("activate", event, uiSortable);
@@ -740,10 +739,6 @@ $.ui.plugin.add("draggable", "connectToSortable", {
740739
inst.cancelHelperRemoval = true;
741740
this.instance.cancelHelperRemoval = false;
742741

743-
//The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
744-
if (this.shouldRevert) {
745-
this.instance.options.revert = this.shouldRevert;
746-
}
747742
// Use _storedCSS To restore properties in the sortable,
748743
// as this also handles revert (#9675) since the draggable
749744
// may have modified them in unexpected ways (#8809)
@@ -859,12 +854,18 @@ $.ui.plugin.add("draggable", "connectToSortable", {
859854
sortable.isOver = 0;
860855
sortable.cancelHelperRemoval = true;
861856

862-
// Prevent reverting on this forced stop
857+
// Calling sortable's mouseStop would trigger a revert,
858+
// so revert must be temporarily false until after mouseStop is called.
859+
sortable.options._revert = sortable.options.revert;
863860
sortable.options.revert = false;
864861

865862
sortable._trigger( "out", event, sortable._uiHash( sortable ) );
866863

867864
sortable._mouseStop( event, true );
865+
866+
// restore sortable behaviors that were modfied
867+
// when the draggable entered the sortable area (#9481)
868+
sortable.options.revert = sortable.options._revert;
868869
sortable.options.helper = sortable.options._helper;
869870

870871
if ( sortable.placeholder ) {

0 commit comments

Comments
 (0)