Bug 217350

Summary: Text input element does not scroll into view when setting focus and selection
Product: WebKit Reporter: Adam Reineke <adam>
Component: FormsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: adam, cdumez, ddkilzer, megan_gardner, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Min repro for the bug
none
Repro without step attribute none

Description Adam Reineke 2020-10-05 16:18:47 PDT
Created attachment 410580 [details]
Min repro for the bug

The input element receives focus but does not scroll into view if you call focus() and a selection API on an input element with the step attribute (except when the exact text selection was already set).

Repro:

1. input type=text with the step attribute set. Note: Any value for step seems to work. I use the empty string.
2. Scroll input off-screen
3. Send focus and set selection at the same time.
 - Note: Setting the selection via any of the selection APIs hits the bug: .select(), .selectionStart and .selectionEnd together, or .setSelectionRange().
 - Note: The selection being set must be different than the current selection to hit the bug.
 - Note: If you click one of the select buttons on the left twice in a row, the input will scroll into view because text selection was unchanged.

Version: Tested in Safari 14.0 (15610.1.28.1.9, 15610) and Safari Technology Preview (Release 113, Safari 14.0.1, Webkit 15610.2.3.1). I expect it also happens in Safari 13 based on the bug report I was investigating when I reduced to this min-repro.

Tested on Mac desktop only.

Test file attached with min repro.
Comment 1 Radar WebKit Bug Importer 2020-10-05 17:10:27 PDT
<rdar://problem/69977571>
Comment 2 Adam Reineke 2020-10-05 18:11:58 PDT
FYI, originally discovered on Salesforce.com but there is no public URL for that repro.

No repro in Chrome 85.
Comment 3 Adam Reineke 2020-10-06 15:04:13 PDT
This actually doesn't require the step attribute.
Comment 4 Adam Reineke 2020-10-06 15:05:13 PDT
Created attachment 410698 [details]
Repro without step attribute

A simpler repro that doesn't include the step="" attribute on the input.