Bug 218005

Summary: REGRESSION (iOS 14): Safari getElementById().focus() for text input via onclick stops working after first time in iFrame
Product: WebKit Reporter: derrick.r.chao
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED WORKSFORME    
Severity: Normal CC: akeerthi, bdakin, bfulgham, cdumez, dbates, megan_gardner, smoley, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: All   
OS: Unspecified   
Attachments:
Description Flags
reduced test case none

Description derrick.r.chao 2020-10-20 16:53:12 PDT
I have an onclick event that triggers a function which then calls getElementById().focus() on a text input. On the first tap, it will work just fine. On subsequent taps, however, it no longer focuses on the text input and it requires the user to tap on the text input. This is for an embedded app in Shopify POS which opens in a Safari Webview and I have also reproduced the behavior in iOS Safari as well (which embeds in an iFrame).

I believe I have isolated the cause of this to updating to iOS 14 (I am testing this on a physical 6th gen iPad). I have verified that on a physical iPhone running iOS 13, xcode iPad emulator running iOS 13.4, and another physical iPad running iOS 12, the .focus() still works as intended.

Pre iOS 14: https://photos.app.goo.gl/hdpHDooFw6LPGdbQ7

After iOS 14 update: https://photos.app.goo.gl/BCbEyqchkFPnJNwM9
Comment 1 Radar WebKit Bug Importer 2020-10-21 17:41:48 PDT
<rdar://problem/70553542>
Comment 2 Smoley 2020-10-28 16:32:06 PDT
Thanks for filing, can you please attach a reduced test case that illustrates this issue?
Comment 3 derrick.r.chao 2020-10-28 19:04:31 PDT
Created attachment 412601 [details]
reduced test case

Please see reduced test case attached. I'm relatively new to web development so it's very possible it might be a bug on my end. When I test this in mobile safari on iOS 14, the keyboard never appears and the focus never happens. 

On xcode simulator iOS 13.3, the focus happens every time.
Comment 4 Smoley 2020-10-29 10:14:06 PDT
Thanks Derrick, that works! I cannot reproduce this on iOS 13.6.1, I can reproduce it on the latest iOS 14.2 beta. I'll get this routed to the right folks.
Comment 5 derrick.r.chao 2021-05-13 09:04:03 PDT
Appears to be resolved in 14.5.1, thank you team.
Comment 6 Brent Fulgham 2022-02-12 22:13:39 PST
Unable to reproduce.