aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorKevin Cupp <kevin.cupp@gmail.com>2015-07-15 21:10:19 -0400
committerScott González <scott.gonzalez@gmail.com>2016-10-04 15:22:14 -0400
commit87eab46a589031d781299937f95f22bf61b5ef27 (patch)
treed17f5c5876bf06ee6a3e1dc5244edf40abe46675 /ui
parentb9d687deb58cce5f4c6e27dace9cb172e291698c (diff)
downloadjquery-ui-87eab46a589031d781299937f95f22bf61b5ef27.tar.gz
jquery-ui-87eab46a589031d781299937f95f22bf61b5ef27.zip
Sortable: Setting table row placeholder height to be same as sorted row
Fixes #13662 Closes gh-1578
Diffstat (limited to 'ui')
-rw-r--r--ui/widgets/sortable.js24
1 files changed, 15 insertions, 9 deletions
diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js
index f7298ebe5..a95350151 100644
--- a/ui/widgets/sortable.js
+++ b/ui/widgets/sortable.js
@@ -875,20 +875,20 @@ return $.widget( "ui.sortable", $.ui.mouse, {
_createPlaceholder: function( that ) {
that = that || this;
- var className,
+ var className, nodeName,
o = that.options;
if ( !o.placeholder || o.placeholder.constructor === String ) {
className = o.placeholder;
+ nodeName = that.currentItem[ 0 ].nodeName.toLowerCase();
o.placeholder = {
element: function() {
- var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
- element = $( "<" + nodeName + ">", that.document[ 0 ] );
+ var element = $( "<" + nodeName + ">", that.document[ 0 ] );
- that._addClass( element, "ui-sortable-placeholder",
- className || that.currentItem[ 0 ].className )
- ._removeClass( element, "ui-sortable-helper" );
+ that._addClass( element, "ui-sortable-placeholder",
+ className || that.currentItem[ 0 ].className )
+ ._removeClass( element, "ui-sortable-helper" );
if ( nodeName === "tbody" ) {
that._createTrPlaceholder(
@@ -917,9 +917,15 @@ return $.widget( "ui.sortable", $.ui.mouse, {
return;
}
- //If the element doesn't have a actual height by itself (without styles coming
- // from a stylesheet), it receives the inline height from the dragged item
- if ( !p.height() ) {
+ // If the element doesn't have a actual height or width by itself (without
+ // styles coming from a stylesheet), it receives the inline height and width
+ // from the dragged item. Or, if it's a tbody or tr, it's going to have a height
+ // anyway since we're populating them with <td>s above, but they're unlikely to
+ // be the correct height on their own if the row heights are dynamic, so we'll
+ // always assign the height of the dragged item given forcePlaceholderSize
+ // is true.
+ if ( !p.height() || ( o.forcePlaceholderSize &&
+ ( nodeName === "tbody" || nodeName === "tr" ) ) ) {
p.height(
that.currentItem.innerHeight() -
parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -