Skip to content

feat(MenuTrigger): Extend selector to match documentation #32616

@michaelkrog

Description

@michaelkrog

Feature Description

The description of MenuTrigger says:

The ngMenuTrigger directive is used to open and close menus. It can be applied to any interactive element (e.g., a button)...

But in the reality the selector is bound to the button element making it cumbersome to use with custom button components.

@Directive({
  selector: 'button[ngMenuTrigger]',
  exportAs: 'ngMenuTrigger',
  ....
})

https://github.com/angular/components/blob/main/src/aria/menu/menu-trigger.ts#L44

Use Case

In our case we have a need to trigger the menu using different elements in our design system fx. our custom button component. The current selector requires us to have a button around our button fx:

<button ngMenuTrigger>
  <lm-button/>
</button>

It causes a focus trap as our custom button is always focusable and ngMenuTrigger forces the wrapping button to also be focusable.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions