Skip to content

Commit 9c5ce4c

Browse files
CyborgMasterscottgonzalez
authored andcommitted
Sortable: Fix z-index switching from auto to 0
Save `z-index` before saving `opacity`. Setting `opacity` automatically changes `z-index`. Fixes #14683 Closes jquerygh-1762
1 parent f1fa076 commit 9c5ce4c

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

ui/widgets/sortable.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,20 +279,23 @@ return $.widget( "ui.sortable", $.ui.mouse, {
279279
$( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
280280
}
281281

282-
if ( o.opacity ) { // opacity option
283-
if ( this.helper.css( "opacity" ) ) {
284-
this._storedOpacity = this.helper.css( "opacity" );
285-
}
286-
this.helper.css( "opacity", o.opacity );
287-
}
288-
282+
// We need to make sure to grab the zIndex before setting the
283+
// opacity, because setting the opacity to anything lower than 1
284+
// causes the zIndex to change from "auto" to 0.
289285
if ( o.zIndex ) { // zIndex option
290286
if ( this.helper.css( "zIndex" ) ) {
291287
this._storedZIndex = this.helper.css( "zIndex" );
292288
}
293289
this.helper.css( "zIndex", o.zIndex );
294290
}
295291

292+
if ( o.opacity ) { // opacity option
293+
if ( this.helper.css( "opacity" ) ) {
294+
this._storedOpacity = this.helper.css( "opacity" );
295+
}
296+
this.helper.css( "opacity", o.opacity );
297+
}
298+
296299
//Prepare scrolling
297300
if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
298301
this.scrollParent[ 0 ].tagName !== "HTML" ) {

0 commit comments

Comments
 (0)