Bug Tracker

Modify

Ticket #8903 (closed bug: worksforme)

Opened 2 years ago

Last modified 23 months ago

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:
Blocking: #4872 Blocked by:

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

comment:1 Changed 2 years ago by timmywil

  • Owner set to anonymous
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to dimensions

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 2 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 follow-up: ↓ 5 Changed 2 years ago by timmywil

  • Status changed from pending to closed
  • Resolution set to invalid

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

comment:4 Changed 2 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 ; follow-up: ↓ 6 Changed 2 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 2 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 2 years ago by timmywil

  • Status changed from closed to reopened
  • Resolution invalid deleted

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

comment:8 follow-up: ↓ 9 Changed 2 years ago by timmywil

  • Status changed from reopened to open
  • Blocked by 4872 added

comment:9 in reply to: ↑ 8 Changed 2 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 2 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 2 years ago by timmywil

  • Blocking 4872 added
  • Blocked by 4872 removed

This has to do with the marginRight hook.

comment:12 Changed 2 years ago by anonymous

This doesn't seem to be broken anymore.

comment:13 Changed 23 months ago by rwaldron

  • Status changed from open to closed
  • Resolution set to worksforme

Cannot reproduce.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.