Opened 12 years ago

Closed 10 years ago

Last modified 10 years ago

#7485 closed bug (fixed)

Resizable: Containment calculation is wrong when containment element is not the immediate parent

Reported by: Hancoque Owned by:
Priority: minor Milestone: 1.11.0
Component: ui.resizable Version: 1.8.13
Keywords: haspatch Cc:
Blocked by: Blocking:

Description

There's a problem with the resizable component when using a containment element that is not the parent of the resizable element.

I found out that the allowed width computation differs from the allowed height computation. There's additional code for the former and it seems that a workaround for the bug is already in place but it is only triggered if the containment element is also the parent element:

var isParent = self.containerElement.get(0) == self.element.parent().get(0),
    isOffsetRelative = /relative|absolute/.test(self.containerElement.css('position'));

if(isParent && isOffsetRelative) woset -= self.parentData.left;

So, a possible approach to fix this bug is to get rid of the isParent check.

Test case: http://jsbin.com/oduba4

Try to resize the blue element to the full width of the gray element. It won't work, though it should. The space missing on the right equals the left offset of the containment element.

While investigating this bug I noticed that there are some other differences between the containment calculations for width and height in the same function as the code posted above is in. You may want to take a look at those differences as removing them also fixes the bug. But I don't know if these differences are there for a reason and address other issues.

Here's an additional subtraction of cop.left at the end:

self.size.width = self.size.width + (self._helper ? (self.position.left - co.left) : (self.position.left - cop.left));

vs

self.size.height = self.size.height + (self._helper ? (self.position.top - co.top) : self.position.top);}

And Here cop is used instead of co in the else-case:

var woset = Math.abs( (self._helper ? self.offset.left - cop.left : (self.offset.left - cop.left)) + self.sizeDiff.width ),

vs

    hoset = Math.abs( (self._helper ? self.offset.top - cop.top : (self.offset.top - co.top)) + self.sizeDiff.height );

Change History (15)

comment:1 Changed 12 years ago by Hancoque

The bug still exists in jQuery UI 1.8.14.

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

Milestone: 1.9.02.0.0

comment:3 Changed 11 years ago by tj.vantoll

Status: newopen
Summary: Containment calculation is wrong when containment element is no parentResizable: Containment calculation is wrong when containment element is not the immediate parent

Still an issue in 1.9.1 - http://jsbin.com/oduba4/3.

comment:4 Changed 11 years ago by tj.vantoll

#8217 is a duplicate of this ticket.

comment:5 Changed 11 years ago by tj.vantoll

Keywords: haspatch added

See duplicate ticket #8217 for a proposed patch.

comment:6 Changed 11 years ago by tj.vantoll

#8895 is a duplicate of this ticket.

comment:7 Changed 11 years ago by tj.vantoll

Here's another good test case from #8895 - http://jsfiddle.net/TkHUE/33/.

comment:8 Changed 11 years ago by tj.vantoll

#9174 is a duplicate of this ticket.

comment:9 Changed 11 years ago by tj.vantoll

#9174 had this test case against master - http://jsfiddle.net/v392b/. And a discussion on what the problem in the code might be.

comment:10 Changed 11 years ago by scato.eggen

this bug is very easy to fix, so why has this issue been open for 21 months?

comment:11 Changed 11 years ago by Scott González

@scato.eggen We've been very busy. Feel free to send a pull request with a unit test!

comment:12 Changed 10 years ago by tj.vantoll

#9540 is a duplicate of this ticket.

comment:14 Changed 10 years ago by Jyoti Deka

Resolution: fixed
Status: openclosed

Resizable: containment now works with non - immediate children

Fixes #7485 Closes gh-1130

Changeset: c03cb8079c6984fb9286a64d980d367d86b9cd8b

comment:15 Changed 10 years ago by mikesherov

Milestone: 2.0.01.11.0
Note: See TracTickets for help on using tickets.