Skip to main content

Search and Top Navigation

#7485 closed bug (fixed)

Opened June 17, 2011 11:01AM UTC

Closed December 15, 2013 05:40PM UTC

Last modified December 15, 2013 05:41PM UTC

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 );
Attachments (0)
Change History (15)

Changed June 30, 2011 07:14AM UTC by Hancoque comment:1

The bug still exists in jQuery UI 1.8.14.

Changed October 11, 2012 02:52PM UTC by scottgonzalez comment:2

milestone: 1.9.02.0.0

Changed October 28, 2012 02:24AM UTC by tj.vantoll comment:3

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.

Changed October 30, 2012 03:20PM UTC by tj.vantoll comment:4

#8217 is a duplicate of this ticket.

Changed October 30, 2012 03:22PM UTC by tj.vantoll comment:5

keywords: → haspatch

See duplicate ticket #8217 for a proposed patch.

Changed December 07, 2012 09:27PM UTC by tj.vantoll comment:6

#8895 is a duplicate of this ticket.

Changed December 07, 2012 09:27PM UTC by tj.vantoll comment:7

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

Changed March 22, 2013 12:18PM UTC by tj.vantoll comment:8

#9174 is a duplicate of this ticket.

Changed March 22, 2013 12:19PM UTC by tj.vantoll comment:9

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

Changed March 22, 2013 02:58PM UTC by scato.eggen comment:10

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

Changed March 22, 2013 03:10PM UTC by scottgonzalez comment:11

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

Changed September 09, 2013 05:17PM UTC by tj.vantoll comment:12

#9540 is a duplicate of this ticket.

Changed November 10, 2013 11:58PM UTC by dekajp comment:13

Changed December 15, 2013 05:40PM UTC by Jyoti Deka comment:14

resolution: → fixed
status: openclosed

Resizable: containment now works with non - immediate children

Fixes #7485

Closes gh-1130

Changeset: c03cb8079c6984fb9286a64d980d367d86b9cd8b

Changed December 15, 2013 05:41PM UTC by mikesherov comment:15

milestone: 2.0.01.11.0