components icon indicating copy to clipboard operation
components copied to clipboard

bug(button): Icon Button Focusing Inconsistent

Open karmasakshi opened this issue 2 years ago • 2 comments

Is this a regression?

  • [ ] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

This bug can be seen on the documentation page of Menu component. If you go to https://material.angular.io/components/menu/examples and scroll down to "Menu with icons" section, the icon button will sometimes be left focused after opening and closing the menu. See below:

https://github.com/angular/components/assets/4698762/8261e82f-a51d-481d-a45b-467f3571429e

One thing to note, I'm seeing this issue only with trackpad taps, not with trackpad clicks. See below:

https://github.com/angular/components/assets/4698762/d818e059-1e3f-4b05-80ea-e70e12e06e36

Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-fntbkn?file=src%2Fmain.ts

Screen Shot 2024-02-17 at 1 25 55 AM

Steps to reproduce:

  1. Click on the icon button to open the menu
  2. Click again on the icon button to close the menu
  3. Move the cursor away from the button
  4. Repeat

Expected Behavior

The focus on the icon button should be gone on hovering away from the button.

Actual Behavior

The focus stays on the button.

Environment

  • Angular: 17.2.1
  • CDK/Material: 17.2.0
  • Browser(s): Chrome, Firefox and Safari latest
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS 12.7.3

karmasakshi avatar Feb 16 '24 21:02 karmasakshi

@karmasakshi I believe for accessibility reasons, the correct behavior is for focus to return to the button after closing the menu.

The unexpected behavior here would be that closing the menu does not return focus to the button

wagnermaciel avatar Feb 23 '24 18:02 wagnermaciel

Hello folks, this may be a systemic issue with Overlay and maybe not only an issue with button and menu components. I noticed in chrome debugger that document.activeelement is the menu trigger when closing popup, but it doesn't display the focus state. I also noticed that when closing with mouse, activeElement changed to body before changing to trigger. -Zach

zarend avatar Feb 26 '24 18:02 zarend