Bug 164512 - element.focus() inside tall iframe scrolls parent to incorrect screen position
Summary: element.focus() inside tall iframe scrolls parent to incorrect screen position
Status: RESOLVED DUPLICATE of bug 186956
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 11
Hardware: iPhone / iPad iOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-11-08 06:22 PST by Coridyn
Modified: 2018-11-12 15:28 PST (History)
4 users (show)

See Also:


Attachments
iframecontent.html (3.60 KB, text/html)
2016-11-08 06:22 PST, Coridyn
no flags Details
reduction (622 bytes, text/html)
2016-11-08 06:23 PST, Coridyn
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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 ***