Bug 220723 - Page scrolls when dispatching space keypress event from an input field
Summary: Page scrolls when dispatching space keypress event from an input field
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: Safari 14
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-01-19 00:52 PST by Mats
Modified: 2021-01-21 18:43 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mats 2021-01-19 00:52:14 PST
When pressing space key inside a textfield, no page scroll is observed. Should work the same for untrusted events, test case below:

Open any page with an input on it, such as: https://bugs.webkit.org/ 


Run this in the console:

const input = $('input[type=text]'); // grab first input on the page

const event = new KeyboardEvent('keypress', {
altKey: false,
bubbles: true,
cancelBubble: false,
cancelable: true,
charCode: 32,
code: "Space",
composed: true,
ctrlKey: false,
currentTarget: null,
defaultPrevented: false,
detail: 0,
eventPhase: 0,
isComposing: false,
key: " ",
keyCode: 0,
location: 0,
metaKey: false,
repeat: false,
returnValue: true,
shiftKey: false,
srcElement: input,
target: input,
type: "keypress",
which: 0
});

input.focus();
input.dispatchEvent(event);

Note that page scrolls.
Comment 1 Radar WebKit Bug Importer 2021-01-21 18:43:15 PST
<rdar://problem/73479284>