question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(cdk/a11y): [Safari] [Chrome] [MacOS] FocusMonitor improperly identifies subsequent right mouse clicks as keyboard focus origin

See original GitHub issue

This was found while stress-testing https://github.com/angular/components/pull/22489.

Reproduction

  1. Go to https://material.angular.io/cdk/a11y/overview#focusmonitor on Chrome
  2. Scroll to the “Monitoring focus with FocusMonitor” example.
  3. Right click on “Child Button 2”. Mouse focus should be detected.
  4. 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:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zelliottcommented, Apr 27, 2021

As for what the right behavior is, I think ideally we could match the behavior of :focus-visible, whatever that is for this case.

I did some quick testing:

  • Subsequent right clicks disable :focus-visible (as expected, of course).
  • Triggering a mouse click with VO (i.e. with VO + Shift + Space) disables :focus-visible.
  • Triggering an element’s default action in VO’s virtual cursor (i.e. with VO + Space) is ignored by :focus-visible (i.e. it remains what it currently is).

Thus, my proposal seems to align with :focus-visible’s behavior.

0reactions
angular-automatic-lock-bot[bot]commented, Aug 2, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found