Bug 139945

Summary: Mouse/Touch Events Can Focus Parent Element
Product: WebKit Reporter: Rodney Rehm <mail>
Component: UI EventsAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, ap, bfulgham, mmaxfield, ntim, simon.fraser, vitor.roriz, webkit, webkit, zalan
Priority: P2 Keywords: HasReduction
Version: WebKit Nightly Build   
Hardware: Mac   
OS: OS X 10.11   
Attachments:
Description Flags
reduced test case none

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!