Bug 164512

Summary: element.focus() inside tall iframe scrolls parent to incorrect screen position
Product: WebKit Reporter: Coridyn <coridyn+bugzilla>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: cdumez, simon.fraser, webkit-bug-importer, yann.armelin
Priority: P2 Keywords: InRadar
Version: Safari 11   
Hardware: iPhone / iPad   
OS: iOS 11   
Attachments:
Description Flags
iframecontent.html
none
reduction none

Description Coridyn 2016-11-08 06:22:32 PST
Created attachment 294157 [details]
iframecontent.html

Calling element.focus() on an element inside an iframe taller than the viewport causes the parent to scroll to an incorrect position.

Scenario: 

1. iframe with content taller than parent viewport (iframe is sized to 100% of its content)
2. iframe has DIV "target" element that sits below viewport page fold
3. Scroll parent page down so "target" element is visible
4. From inside iframe call element.focus() on "target" element
5. The parent page will attempt to scroll the "target" element into view but instead scrolls screen to wrong position so "target" element is no longer visible.

With this issue it's not possible to set focus on an HTML element without the target element being scrolled off-screen.

Notes:

 - The issue occurs in iOS 10.1.1 and iOS 10.2 beta 2.
 - The issue doesn't occur in iOS 9.3.2.
 - The issue only occurs when focussing on non-input HTML elements e.g. DIV, SPAN, anchor tags.
 - The issue doesn't occur when setting focus on INPUT elements (parent page scrolls to the correct location).
Comment 1 Coridyn 2016-11-08 06:23:49 PST
Created attachment 294158 [details]
reduction
Comment 2 Radar WebKit Bug Importer 2016-11-08 08:21:44 PST
<rdar://problem/29159287>
Comment 3 Yann Armelin 2018-06-04 01:59:34 PDT
Issue also occurs when element.scrollIntoView() is called from an iframe.

It's still reproducable on last Webkit version compiled locally.
Comment 4 Simon Fraser (smfr) 2018-11-12 15:28:45 PST
This was fixed by bug 186956.

*** This bug has been marked as a duplicate of bug 186956 ***