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