Sortable: Allow 0-height containers to be sortable as in 1.12.1

Note that container specific events will not fire when the dragged element
is interacting with zero height containers.

Fixes gh-1998
Closes gh-2008

Co-authored-by: A. Wells <borgboyone@users.noreply.github.com>
This commit is contained in:
Michał Gołębiowski-Owczarek 2021-11-08 18:21:03 +01:00 committed by GitHub
parent 85fba3f107
commit efe3b22517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 118 additions and 72 deletions

View File

@ -42,4 +42,57 @@ QUnit.test( "ui-sortable-handle applied to appropriate element", function( asser
assert.equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" ); assert.equal( el.find( ".ui-sortable-handle" ).length, 0, "class name removed on destroy" );
} ); } );
// gh-1998
QUnit.test( "drag & drop works with a zero-height container", function( assert ) {
var ready = assert.async();
assert.expect( 3 );
var el = $( "<ul class='list-gh-1998'>\n" +
" <style>" +
" .list-gh-1998 {\n" +
" margin: 0;\n" +
" padding: 0;\n" +
" }\n" +
" .list-item-gh-1998 {\n" +
" float: left;\n" +
" display: block;\n" +
" width: 100px;\n" +
" height: 100px;\n" +
" }\n" +
" </style>\n" +
" <li class='list-item-gh-1998'>Item 1</li>\n" +
" <li class='list-item-gh-1998'>Item 2</li>\n" +
" <li class='list-item-gh-1998'>Item 3</li>\n" +
"</ul>" )
.sortable()
.appendTo( "#qunit-fixture" );
function step1() {
el.find( "li" ).eq( 0 ).simulate( "drag", {
dx: 100,
dy: 3,
moves: 3
} );
setTimeout( step2 );
}
function step2() {
el.find( "li" ).eq( 2 ).simulate( "drag", {
dx: -200,
dy: -3,
moves: 3
} );
setTimeout( step3 );
}
function step3() {
assert.equal( el.find( "li" ).eq( 0 ).text(), "Item 3" );
assert.equal( el.find( "li" ).eq( 1 ).text(), "Item 2" );
assert.equal( el.find( "li" ).eq( 2 ).text(), "Item 1" );
ready();
}
step1();
} );
} ); } );

View File

@ -421,11 +421,6 @@ return $.widget( "ui.sortable", $.ui.mouse, {
this.helper[ 0 ].style.top = this.position.top + "px"; this.helper[ 0 ].style.top = this.position.top + "px";
} }
//Post events to containers
this._contactContainers( event );
if ( this.innermostContainer !== null ) {
//Do scrolling //Do scrolling
if ( o.scroll ) { if ( o.scroll ) {
if ( this._scroll( event ) !== false ) { if ( this._scroll( event ) !== false ) {
@ -492,7 +487,9 @@ return $.widget( "ui.sortable", $.ui.mouse, {
break; break;
} }
} }
}
//Post events to containers
this._contactContainers( event );
//Interconnect with droppables //Interconnect with droppables
if ( $.ui.ddmanager ) { if ( $.ui.ddmanager ) {
@ -888,9 +885,7 @@ return $.widget( "ui.sortable", $.ui.mouse, {
this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) : this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
false; false;
if ( this.innermostContainer !== null ) {
this._refreshItemPositions( fast ); this._refreshItemPositions( fast );
}
var i, p; var i, p;
@ -1038,8 +1033,6 @@ return $.widget( "ui.sortable", $.ui.mouse, {
} }
this.innermostContainer = innermostContainer;
// If no intersecting containers found, return // If no intersecting containers found, return
if ( !innermostContainer ) { if ( !innermostContainer ) {
return; return;