Bug Tracker

Opened 15 years ago

Closed 15 years ago

#1843 closed bug (fixed)

Calling width/height() on a hidden element causes cursor to move to the end of textarea

Reported by: DanSwitzer2 Owned by:
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:


There appears to be an issue in Firefox v2.0.0.8 and the width/height() methods.

If you call them on an element which is hidden and the user is typing in a textarea box, then the cursor jumps to the end of the textarea box.

This does not happen with the css() method.

I've prepared a page that demonstrates the behavior: http://www.pengoworks.com/workshop/jquery/jquery_height_issue.htm

If you make the hidden div visible, it works as expected. If you use the css() method it works as expected.

Some more digging, it appears the problem only exists when the hidden element is a child of the body tag.

I've tracked the problem down to the jQuery.css function. If you change the lines:

if ( parPos == "static" )

e.parentNode.style.position = "relative";

to: if ( parPos == "static" && e.parentNode.tagName != "BODY" )

e.parentNode.style.position = "relative";

This seems to resolve the problem. Apparently changing the position of the BODY tag in FF causes some kind of document reset.

Change History (2)

comment:1 Changed 15 years ago by DanSwitzer2

This appears to be related to #1415 and http://dev.jquery.com/ticket/1629#1629

comment:2 Changed 15 years ago by brandon

Resolution: fixed
Status: newclosed

Fixed in Rev [4100].

Note: See TracTickets for help on using tickets.