Bug 16812 - onFocus causes cursor to be in wrong location if MobileSafari resizes page
Summary: onFocus causes cursor to be in wrong location if MobileSafari resizes page
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: 420+
Hardware: Other Other
: P2 Normal
Assignee: Nobody
URL: http://www.whiterose.org/test/onfocus...
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2008-01-09 20:44 PST by Michael Croft
Modified: 2008-01-09 20:53 PST (History)
2 users (show)

See Also:


Attachments
reduced test case (674 bytes, text/html)
2008-01-09 20:46 PST, Michael Croft
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Croft 2008-01-09 20:44:35 PST
[If you're not looking for/at MobileSafari bugs here, my apologies.  If you are, might be worthwhile to add platform/OS for it...]

OS iPhone 3B48b (1.1.2) 

This page uses onfocus to clear an example value in a text input field.  This works fine in Safari (and other browsers) but causes a focus problem in Mobile Safari (in portrait orientation).  The key code is 
input type="text" name="IphoneNumber" value="ex. 5125551212" onfocus="this.value=''"

If I take out onfocus, this works fine.

We were unable to duplicate the problem with iPhone software 1.0.2

Steps to reproduce:
1: open the attached page in portrait mode on an iPhone
2: touch the text field
expected results: the field becomes blank and the cursor moves to the first character in the field.
actual results: the cursor and the focus are somewhere before the field.  Typing can happen, but it's not in the right field.

I've tried this with different doctypes and with and without the viewport meta setting.  The page validates.  There is no problem if the form is the first item on the page or if the iPhone is in landscape mode (no scaling happens).  The H1 element is involved, if only because of the width of the page.  If the scaling has already occurred (such as if you re-open the page while it's already the right size for the form), the focus goes to the right place.

Reduction at the URL listed.
Comment 1 Michael Croft 2008-01-09 20:46:56 PST
Created attachment 18360 [details]
reduced test case
Comment 2 Mark Rowe (bdash) 2008-01-09 20:48:24 PST
Bugs in Safari on the iPhone should be reported in Radar at http://bugreport.apple.com/.  I'm going to migrate this bug to Radar and close this bug.
Comment 3 Mark Rowe (bdash) 2008-01-09 20:49:37 PST
<rdar://problem/5680715>