Bug 257217 - Removing positioned element from DOM with a focused input can jump to the bottom of the page
Summary: Removing positioned element from DOM with a focused input can jump to the bot...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 16
Hardware: Mac (Apple Silicon) macOS 13
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-05-23 12:03 PDT by Jordan Pittman
Modified: 2023-05-30 12:04 PDT (History)
4 users (show)

See Also:


Attachments
A file that showcases the bug (2.71 KB, text/html)
2023-05-23 12:03 PDT, Jordan Pittman
no flags Details
A video showcasing the buggy behavior (5.83 MB, video/quicktime)
2023-05-23 12:04 PDT, Jordan Pittman
no flags Details

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