Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(MENU): Make content-projection for icon possible for any other icon definitions like fa-icon or <i> #26214

Closed
anschm opened this issue Dec 8, 2022 · 3 comments · Fixed by #26235
Assignees
Labels
area: material/menu P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@anschm
Copy link

anschm commented Dec 8, 2022

Feature Description

Feature Description

Actually the menu item HTML is implemented like this:

<ng-content select="mat-icon"></ng-content>
<span class="mdc-list-item__primary-text"><ng-content></ng-content></span>
<div class="mat-mdc-menu-ripple" matRipple
     [matRippleDisabled]="disableRipple || disabled"
     [matRippleTrigger]="_getHostElement()">
</div>
<svg
  *ngIf="_triggersSubmenu"
  class="mat-mdc-menu-submenu-icon"
  viewBox="0 0 5 10"
  focusable="false"><polygon points="0,0 5,5 0,10"/></svg>

We can see that the mat-icon is projected into the menu item by using the selector mat-icon. This has the limitation to use the menu item only with mat-icon if the menu should have an icon. But whats about fa-icon or ?

It would be great to add a menu item like:

  <button mat-menu-item(click)="click()">
    <fa-icon [icon]="faIcon"></fa-icon>
   <span>...</span>
  </button>

In this case the fa-icon contains a svg like mat-icon can do. It would be cool to project fa-icon into the menu item like mat-icon. This can be done with a directive name like icon or any other name.

Use Case

Use mat-menu-item also with other icon components like or fa-icon.

Use Case

No response

@anschm anschm added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Dec 8, 2022
@crisbeto crisbeto self-assigned this Dec 10, 2022
@crisbeto crisbeto added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent area: material/menu and removed needs triage This issue needs to be triaged by the team feature This issue represents a new feature or feature request rather than a bug or bug fix labels Dec 10, 2022
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 10, 2022
Adds the `matMenuItemIcon` selector to the `ng-content` so icons that aren't `mat-icon` can be projected in the correct place.

Fixes angular#26214.
@crisbeto
Copy link
Member

Adding all the possible icon selectors to our template wouldn't be feasible, but I've opened #26235 which adds a matMenuItemIcon attribute that you can set on your icons to project them in the correct place.

@anschm
Copy link
Author

anschm commented Dec 12, 2022

Thats exactly what I am looking for. Could we get this in 15.0.3?

crisbeto added a commit that referenced this issue Dec 13, 2022
…26235)

Adds the `matMenuItemIcon` selector to the `ng-content` so icons that aren't `mat-icon` can be projected in the correct place.

Fixes #26214.
crisbeto added a commit that referenced this issue Dec 13, 2022
…26235)

Adds the `matMenuItemIcon` selector to the `ng-content` so icons that aren't `mat-icon` can be projected in the correct place.

Fixes #26214.

(cherry picked from commit 1cc831c)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/menu P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants