bug(cdkMenu): Accessibility Issue (context-) menu #30666
Labels
area: cdk/menu
P3
An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Is this a regression?
The previous version in which this bug was not present was
No response
Description
When a (context-) menu is opened and then closed, the
aria-controls
attribute on the host is not cleared.When opening the menu, following happens:
cdk-menu-1
(the number increases with each time opening the context menu)aria-controls="cdk-menu-1"
attributeWhen the menu closes:
aria-controls
attribute stays ❌This is an accessibility error, since it references an id which is not present in the DOM. Tools for automated accessibility testing will report this, like accessibilityinsights in the attached screenshot from the angular material cdk menu example page:

Reproduction
StackBlitz link: https://stackblitz.com/edit/bt5mp6y6 (Fork from the stackblitz of the first example of the cdkMenu page https://material.angular.io/cdk/menu/examples)
Steps to reproduce:
=> When inspecting the DOM you can see the
aria-controls
attribute, but the referenced id is not present in the DOM.Expected Behavior
aria-controls
attribute is removed when the referenced menu is removed from the DOM.Actual Behavior
aria-controls
attribute is present referencing an id not present in the DOM.Environment
The text was updated successfully, but these errors were encountered: