bug(cdk/a11y): [Safari] [Chrome] [MacOS] FocusMonitor improperly identifies subsequent right mouse clicks as keyboard focus origin
See original GitHub issueThis was found while stress-testing https://github.com/angular/components/pull/22489.
Reproduction
- Go to https://material.angular.io/cdk/a11y/overview#focusmonitor on Chrome
- Scroll to the “Monitoring focus with FocusMonitor” example.
- Right click on “Child Button 2”. Mouse focus should be detected.
- Now right click on “Child Button 1”. Observe that keyboard focus is incorrectly detected.
Expected Behavior
I expect mouse focus to be detected.
Actual Behavior
Keyboard focus was detected.
Cause
The second right-click event, on Chrome, is emitted with event.buttons === 0
. This causes the isFakeMousedownFromScreenReader
function to determine that it’s a fake mousedown, which causes FocusMonitor
to attribute it as keyboard instead of mouse.
One idea: Can we update the isFakeMousedownFromScreenReader
method to instead look at the event.offsetX
and event.offsetY
of the mouse event? That might be a better heuristic. I don’t have the context/history into this method though. @crisbeto @jelbourn
Environment
- Angular: Latest
- CDK/Material: Latest
- Browser(s): Chrome 89.0.4389.128
- Operating System (e.g. Windows, macOS, Ubuntu): macOS BigSur
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Unwanted Focus switches - Google Groups
Occasionally I'm typing away (say here or in Excel or Word or the Chrome address/searchbar or whatever) and the focus switches suddenly out...
Read more >5212 - BUG: Chrome does not respond to a mouse click at times
Just a simple right click on a link to open in a new tab, and I'm pounding on my touchpad (or buttons, makes...
Read more >@angular/cdk | Yarn - Package Manager
Designing and Implementing a CDK combobox component; Continuing to focus on improving the accessibility of Angular Material components. About the team. The ...
Read more >Mac OS focus on right-click - Super User
The issue is mainly when opening new Tab in Chrome by right clicking and then the cursor appears. When we start typing, it...
Read more >Big Sur - unable to focus any app or make mouse/keyboard ...
Commonalities: MacBook Pro 16 (2019) i9 Radeon 5500M, Big Sur 11.0.1. I have 2 USB3 docks, each with an HDMI external monitor and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I did some quick testing:
:focus-visible
(as expected, of course).:focus-visible
.:focus-visible
(i.e. it remains what it currently is).Thus, my proposal seems to align with
:focus-visible
’s behavior.This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.