Opened 9 years ago

Closed 6 years ago

#5959 closed bug (invalid)

"offsetParent[0] is undefined" error in sortable

Reported by: kamity Owned by: kamity
Priority: major Milestone: 2.0.0
Component: ui.sortable Version: 1.8.4
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by mikesherov)

I have a draggable list on the page, whose items are connected to multiple sortable lists using 'connectToSortable'. When I drag the first element and drop in to one of the sortables, it works fine. But on subsequent operations, the drag/drop fails with the following errors in the FF (3.6.8) console.

Error: this.offsetParent[0] is undefined
Source File:
Line: 3871

Error: scroll[0] is undefined
Source File:
Line: 3960

After changing the method _getParentOffset in jquery-ui-1.8.4.custom.js as follows, it works fine. Is this a valid fix?

        _getParentOffset: function() {

                //Get the offsetParent and cache its position
                this.offsetParent = this.helper.offsetParent();
                var po = this.offsetParent.offset();

                // This is a special case where we need to modify a offset calculated on start, since the following happened:
                // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
                // 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] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
                        po.left += this.scrollParent.scrollLeft();
               += this.scrollParent.scrollTop();
                var isOffsetParentFound = (this.offsetParent != null && this.offsetParent[0] != null);

                if((this.offsetParent[0] == document.body) //This needs to be actually done for all browsers, since pageX/pageY includes this information
                || (isOffsetParentFound && this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie)) //Ugly IE fix
                        po = { top: 0, left: 0 };
                if (po == null)
                        po = { top: 0, left: 0 };

                return {
                        top: + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
                        left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)



Change History (5)

comment:1 Changed 8 years ago by Scott González

Priority: blockermajor

comment:2 Changed 6 years ago by Scott González

Milestone: TBD2.0.0

comment:3 Changed 6 years ago by mikesherov

Description: modified (diff)

comment:4 Changed 6 years ago by mikesherov

Owner: set to kamity
Status: newpending

Thanks for taking the time to contribute to the jQuery UI project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the git version of both jQuery UI and jQuery to ensure the issue still exists. To get you started, use this boilerplate: Open the link and click to "Fork" (in the top menu) to get started.

comment:5 Changed 6 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.