Bug 257217

Summary: Removing positioned element from DOM with a focused input can jump to the bottom of the page
Product: WebKit Reporter: Jordan Pittman <jordan>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: megan_gardner, rniwa, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: Mac (Apple Silicon)   
OS: macOS 13   
Attachments:
Description Flags
A file that showcases the bug
none
A video showcasing the buggy behavior none

Description Jordan Pittman 2023-05-23 12:03:08 PDT
Created attachment 466466 [details]
A file that showcases the bug

I checked this bug against Safari 16.5 *and* the latest Safari Tech Preview.

If you have an element which is either `position: absolute` or `position: fixed`;
That was just inserted into the DOM; AND
It contains a focused input element (either programmatic or because of `autofocus`); AND
A key event is wired up to remove the positioned element it can result in jumping to the bottom of the page.

The specifics surrounding this are quite weird but:
1. It requires that a user NOT interact with the input at all by focusing, typing text, or clicking.
2. It requires that there be an element with content below the viewport
3. And that element must be visible (`display: none` and `visibility: hidden` counteract the error)
4. That element must have a computed height that is at least `0.02px` (tested on my Mac Book Pro, 16-inch, 2021 with M1 Max)

The issue is definitely repeatable on the same page.

I've included a reproduction of this — with quite a bit more detail on different things I've tried and what I've seen that works and does not.
Comment 1 Jordan Pittman 2023-05-23 12:04:27 PDT
Created attachment 466467 [details]
A video showcasing the buggy behavior

Here is a video that also shows what happens
Comment 2 Radar WebKit Bug Importer 2023-05-30 12:04:17 PDT
<rdar://problem/110018370>