Skip to content

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

Closed
@zelliott

Description

@zelliott

This was found while stress-testing #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

Metadata

Metadata

Assignees

Labels

AccessibilityThis issue is related to accessibility (a11y)P2The issue is important to a large percentage of users, with a workaroundarea: cdk/a11y

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions