Bug 139945 - Mouse/Touch Events Can Focus Parent Element
Summary: Mouse/Touch Events Can Focus Parent Element
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: WebKit Nightly Build
Hardware: Mac OS X 10.11
: P2 Normal
Assignee: Nobody
URL:
Keywords: HasReduction
Depends on:
Blocks:
 
Reported: 2014-12-25 09:34 PST by Rodney Rehm
Modified: 2022-08-29 17:54 PDT (History)
10 users (show)

See Also:


Attachments
reduced test case (790 bytes, text/html)
2014-12-25 09:34 PST, Rodney Rehm
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rodney Rehm 2014-12-25 09:34:11 PST
Created attachment 243744 [details]
reduced test case

reduced test case: http://medialize.github.io/ally.js/tests/browser-bugs/webkit-pointer-focus-parent.html

Clicking on an <a> element nested in a <div tabindex="-1"> will cause the <div> to receive focus. If anything should receive focus, it should be the <a> element. This behavior can be observed for mousedown and touchstart.

A way to circumvent this behavior is upon mousedown removing all parental tabindex attributes, so once the mousedown handler finished the only naturally focusable element remaining is the element actually clicked upon. On mouseup the tabindex attributes must be restored. The same applies to touchstart and touchend/touchcancel.
Comment 1 Ahmad Saleem 2022-08-29 14:56:28 PDT
I am able to reproduce this bug in Safari Technology Preview 152 using attached reduction and clicking on first case where <a> with tab index = 1, it leads to <div> having focus and the 'red' outline is extended to whole visual viewport while in case of other browsers, it is limited to similar to other case, where tab index is negative 1 and just limit to <a> text.

All other browsers (Chrome Canary 107 and Firefox Nightly 106) work similar in both cases and match each other. Thanks!