Skip to main content

Bug Tracker

Side navigation

#8903 closed bug (worksforme)

Opened April 18, 2011 01:58PM UTC

Closed July 12, 2011 08:03PM UTC

outerWidth(true) Causes Window location to jump to top of window in Chrome

Reported by: anonymous Owned by: anonymous
Priority: low Milestone: 1.next
Component: dimensions Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:
Description

After upgrading to jQuery 1.5.2, calling $("#appWrap").outerWidth(true) causes the page location to jump to the top of the page. I'm unable to reproduce a broken down test case, but it only occurs on a specific wrapping div around the whole page.

Downgrading to jQuery 1.5.1 fixes the issue, as does downgrading to jQuery 1.4.4. I can also reproduce the issue when calling "$("#appWrap").outerWidth(true);" inside of the console and outside of my code.

This issue only happens in Chrome 10 that I've been able to reproduce.

Attachments (0)
Change History (13)

Changed April 18, 2011 03:07PM UTC by timmywil comment:1

component: unfileddimensions
owner: → anonymous
priority: undecidedlow
status: newpending

Thanks for taking the time to contribute to the jQuery project!

I've created a test case based on your description and was unable to reproduce the issue experienced.

http://jsfiddle.net/timmywil/PedcV/show/

Please provide a test case on http://jsfiddle.net or update mine above. Additionally, test against the jQuery (edge) version to ensure the issue still exists.

Changed April 18, 2011 05:50PM UTC by mike.hemesath@gmail.com comment:2

I was able to reduce the problem down. It appears that having a form with a text/search input with the autofocus attribute as a child (or descendant?) of the container being evaluated with outerWidth(true) will trigger the jump.

The reduced test case is here: http://jsfiddle.net/wGY6P/show/

Changed April 18, 2011 07:13PM UTC by timmywil comment:3

resolution: → invalid
status: pendingclosed

That actually makes sense. Focusing on the element brings it into view. This is default browser behavior.

Changed April 18, 2011 07:26PM UTC by Mike Hemesath <mike.hemesath@gmail.com> comment:4

I understand the purpose of the autofocus attribute.

What I dont' understand is why after the page loads and autofocus has been set and I've focused onto different inputs does focus get set AGAIN onto the input when calling $("#test").outerWidth(true).

To be sure this isn't autofocus, do the following:

#1 Let example execute: http://jsfiddle.net/wGY6P/show/

#2 Scroll to bottom of example

#3 Run $("#test").outerWidth(true)

  • Also, not that $("#test").outerHeight(true) does NOT cause the page to jump.

Changed April 18, 2011 07:35PM UTC by Mike Hemesath <mike.hemesath@gmail.com> comment:5

Replying to [comment:3 timmywil]:

That actually makes sense. Focusing on the element brings it into view. This is default browser behavior.

Here's an example of the bug on jQuery's own site.

1. Navigate to http://api.jquery.com/

2. Open Console

3. Run $("#jq-primarySearch").attr("autofocus", true).parent().outerWidth(true);

Changed April 18, 2011 07:36PM UTC by Mike Hemesath <mike.hemesath@gmail.com> comment:6

Replying to [comment:5 Mike Hemesath <mike.hemesath@…>]:

Replying to [comment:3 timmywil]: > That actually makes sense. Focusing on the element brings it into view. This is default browser behavior. Here's an example of the bug on jQuery's own site. 1. Navigate to http://api.jquery.com/ 2. Open Console 3. Run $("#jq-primarySearch").attr("autofocus", true).parent().outerWidth(true);

Be sure to scroll to the bottom of the page before running the test case on api.jquery.com

Changed April 18, 2011 07:38PM UTC by timmywil comment:7

resolution: invalid
status: closedreopened

Ah, you're right. I think this is related to #4872 then.

Changed April 18, 2011 07:38PM UTC by timmywil comment:8

blockedby: → 4872
status: reopenedopen

Changed April 18, 2011 07:41PM UTC by Mike Hemesath <mike.hemesath@gmail.com> comment:9

Replying to [comment:8 timmywil]:

That bug was opened 22months ago? This issue can be resolved by downgrading jquery to 1.5.1 or 1.4.x. It appears it was broken in the last release.

Changed April 30, 2011 05:07PM UTC by kylejginavan@gmail.com comment:10

I am also having a similar issue with I upgrade to a version greater than 1.5.1. Are you sure #4872 is blocking this issue?

Changed April 30, 2011 05:58PM UTC by timmywil comment:11

blockedby: 4872
blocking: → 4872

This has to do with the marginRight hook.

Changed June 30, 2011 03:35PM UTC by anonymous comment:12

This doesn't seem to be broken anymore.

Changed July 12, 2011 08:03PM UTC by rwaldron comment:13

resolution: → worksforme
status: openclosed

Cannot reproduce.