Bug 217350 - Text input element does not scroll into view when setting focus and selection
Summary: Text input element does not scroll into view when setting focus and selection
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: Safari 14
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-10-05 16:18 PDT by Adam Reineke
Modified: 2020-10-09 18:21 PDT (History)
6 users (show)

See Also:


Attachments
Min repro for the bug (3.36 KB, text/html)
2020-10-05 16:18 PDT, Adam Reineke
no flags Details
Repro without step attribute (3.18 KB, text/html)
2020-10-06 15:05 PDT, Adam Reineke
no flags Details

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