diff options
author | Jeremy Mickelson <Jeremy.Mickelson@gmail.com> | 2016-10-13 11:48:19 -0600 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2016-10-19 14:46:47 -0400 |
commit | 9c5ce4c3e986136b8dce14b6b1ccd5296d932f01 (patch) | |
tree | 8baaa22a3a4266d4951645992d1caf1d32d93881 | |
parent | f1fa076f62e99089257f6f8159cb2ce503f0abc2 (diff) | |
download | jquery-ui-9c5ce4c3e986136b8dce14b6b1ccd5296d932f01.tar.gz jquery-ui-9c5ce4c3e986136b8dce14b6b1ccd5296d932f01.zip |
Sortable: Fix `z-index` switching from `auto` to `0`
Save `z-index` before saving `opacity`. Setting `opacity` automatically
changes `z-index`.
Fixes #14683
Closes gh-1762
-rw-r--r-- | ui/widgets/sortable.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js index a95350151..fcb33ace1 100644 --- a/ui/widgets/sortable.js +++ b/ui/widgets/sortable.js @@ -279,13 +279,9 @@ return $.widget( "ui.sortable", $.ui.mouse, { $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body ); } - if ( o.opacity ) { // opacity option - if ( this.helper.css( "opacity" ) ) { - this._storedOpacity = this.helper.css( "opacity" ); - } - this.helper.css( "opacity", o.opacity ); - } - + // We need to make sure to grab the zIndex before setting the + // opacity, because setting the opacity to anything lower than 1 + // causes the zIndex to change from "auto" to 0. if ( o.zIndex ) { // zIndex option if ( this.helper.css( "zIndex" ) ) { this._storedZIndex = this.helper.css( "zIndex" ); @@ -293,6 +289,13 @@ return $.widget( "ui.sortable", $.ui.mouse, { this.helper.css( "zIndex", o.zIndex ); } + if ( o.opacity ) { // opacity option + if ( this.helper.css( "opacity" ) ) { + this._storedOpacity = this.helper.css( "opacity" ); + } + this.helper.css( "opacity", o.opacity ); + } + //Prepare scrolling if ( this.scrollParent[ 0 ] !== this.document[ 0 ] && this.scrollParent[ 0 ].tagName !== "HTML" ) { |