Bug Tracker

Opened 8 years ago

Closed 8 years ago

#8903 closed bug (worksforme)

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: #4872

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.

Change History (13)

comment:1 Changed 8 years ago by timmywil

Component: unfileddimensions
Owner: set to 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.

comment:2 Changed 8 years ago by mike.hemesath@…

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/

comment:3 Changed 8 years ago by timmywil

Resolution: invalid
Status: pendingclosed

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

comment:4 Changed 8 years ago by Mike Hemesath <mike.hemesath@…>

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.

comment:5 in reply to:  3 ; Changed 8 years ago by Mike Hemesath <mike.hemesath@…>

Replying to 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);

comment:6 in reply to:  5 Changed 8 years ago by Mike Hemesath <mike.hemesath@…>

Replying to Mike Hemesath <mike.hemesath@…>:

Replying to 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

comment:7 Changed 8 years ago by timmywil

Resolution: invalid
Status: closedreopened

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

comment:8 Changed 8 years ago by timmywil

Blocked by: 4872 added
Status: reopenedopen

comment:9 in reply to:  8 Changed 8 years ago by Mike Hemesath <mike.hemesath@…>

Replying to 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.

comment:10 Changed 8 years ago by kylejginavan@…

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?

comment:11 Changed 8 years ago by timmywil

Blocked by: 4872 removed
Blocking: 4872 added

This has to do with the marginRight hook.

comment:12 Changed 8 years ago by anonymous

This doesn't seem to be broken anymore.

comment:13 Changed 8 years ago by Rick Waldron

Resolution: worksforme
Status: openclosed

Cannot reproduce.

Note: See TracTickets for help on using tickets.