From 4965ad98dbf5b9098e0d5ec3de99e58e785521f9 Mon Sep 17 00:00:00 2001 From: krzysztof-grzybek Date: Tue, 24 Apr 2018 21:35:38 +0200 Subject: [PATCH] Sortable: fix element position Fixes #15274 --- ui/widgets/sortable.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ui/widgets/sortable.js b/ui/widgets/sortable.js index 78fad26b9b4..eff5f4c3bbf 100644 --- a/ui/widgets/sortable.js +++ b/ui/widgets/sortable.js @@ -1177,6 +1177,12 @@ return $.widget( "ui.sortable", $.ui.mouse, { //Get the offsetParent and cache its position this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); + var scroll = this.cssPosition === "absolute" && + !( this.scrollParent[ 0 ] !== this.document[ 0 ] && + $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? + this.offsetParent : + this.scrollParent, + scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName ); // This is a special case where we need to modify a offset calculated on start, since the // following happened: @@ -1185,8 +1191,7 @@ return $.widget( "ui.sortable", $.ui.mouse, { // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't // the document, which means that the scroll is included in the initial calculation of the // offset of the parent, and never recalculated upon drag - if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] && - $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) { + if ( !scrollIsRootNode ) { po.left += this.scrollParent.scrollLeft(); po.top += this.scrollParent.scrollTop(); }