Bug 226148 - window.onkeydown event.target returns html element when focused on checkbox input element
Summary: window.onkeydown event.target returns html element when focused on checkbox i...
Status: RESOLVED DUPLICATE of bug 22261
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: Safari 14
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-05-22 17:21 PDT by John A. Bilicki III
Modified: 2021-05-24 15:02 PDT (History)
3 users (show)

See Also:


Attachments
Test case to easily demonstrate the bug and a small work-around. (2.37 KB, application/xhtml+xml)
2021-05-22 17:21 PDT, John A. Bilicki III
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John A. Bilicki III 2021-05-22 17:21:39 PDT
Created attachment 429442 [details]
Test case to easily demonstrate the bug and a small work-around.

While this bug is simple how I came across it isn't so I will try to explain it as best as I can and produce a publicly accessible page so others can easily reproduce this bug.

The window.onkeydown's event.target is returning the html element instead of the input checkbox element that was clicked.

I sometimes get excessive test emails (e.g. working on a cron job) and sometimes my inbox is half-full with these emails so I can't use the check-all checkbox or obviously I'd select other emails that I do not want to delete. I spent some time earlier creating a script that when pressing the up or down arrow key will make the corresponding checkbox above or below match the window.onkeydown/event.target's checked state so I can select the emails I want to delete much faster than manually clicking on ~50 checkbox input elements.

I've attached a test case that also includes a non-intuitive work-around. The input checkbox elements are NOT inside of label elements to reduce potential confusion. Blink/Chrome and Gecko/Waterfox/Firefox correctly reference the input element instead of the html element in this circumstance.
Comment 1 Alexey Proskuryakov 2021-05-24 15:02:45 PDT
This is correct behavior - clicking on the checkbox doesn't focus it on macOS.

*** This bug has been marked as a duplicate of bug 22261 ***