Skip to content

bug(cdk/menu): menu is closed on mousedown event #27878

Open

Description

@szulik153

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

14

Description

When menu is opened, using standalone trigger, it is closed by clicking outside the menu on mousedown event.

Reproduction

  1. Go to the CDK menu examples page: https://material.angular.io/cdk/menu/examples.
  2. Open the menu using "Click me!" button under "Menu with Standalone Trigger".
  3. Click outside the menu.

Expected Behavior

Menu should be closed using mouseup event to comply with WCAG Level A - 2.5.2 criterion (https://www.w3.org/TR/WCAG21/#pointer-cancellation)

Actual Behavior

Menu is closed with mousedown event.
The same bahavior appears in CDK v15 - https://v15.material.angular.io/cdk/menu/examples
But not in v14 - https://v14.material.angular.io/cdk/menu/examples

Also latest Material Menu component works as expected - https://material.angular.io/components/menu/examples

Environment

  • Angular: 15, 16
  • CDK/Material: 15, 16
  • Browser(s): latest Chrome, Firefox, Safari
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS (14.0 and 13.6)

Activity

  1. added
    needs triage
    on Oct 3, 2023
  2. crisbeto commented on Oct 3, 2023

    @crisbeto
    Member

    It looks like it's closing on blur before the outside click listener even has the chance to fire. I narrowed it down to this change: crisbeto@b8ccf03#diff-0b5ad517ddf61ce45e4d5b9d872030f1c031d5862892644389e83f55de1d6b3aR307-R314

    @mmalerba do you remember the context behind it? I tried removing that listener and all the tests passed.

  3. added
    P3
    Accessibility
    and removed
    needs triage
    on Oct 3, 2023
  4. mmalerba commented on Oct 5, 2023

    @mmalerba
    Contributor

    It's been a while, so I don't really remember. I think that PR was mostly just code cleanup that wasn't supposed to change behavior, but I might have thrown in a few fixes for issues I saw in the dev-app as well. If the tests pass and you don't notice anything strange in the dev-app demos then its probably fine to remove

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AccessibilityP3area: cdk/menu

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions