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

bug(menu): mat-menu-item > mat-icon - color attribute doesn't work with dynamic assignment #14151

Closed
TheCom3di4n opened this issue Nov 15, 2018 · 1 comment · Fixed by #14161
Assignees
Labels
P4 A relatively minor issue that is not relevant to core functions

Comments

@TheCom3di4n
Copy link

Bug, feature request, or proposal:

Bug

What is the expected behavior?

That the color attribute of the mat-menu-item > mat-icon should work with dynamic assignment.

What is the current behavior?

The color attribute of the mat-menu-item > mat-icon doesn't work with dynamic assignment.

What are the steps to reproduce?

https://stackblitz.com/edit/angular-material2-issue-mat-menu-item-icon-color-attribute

What is the use-case or motivation for changing an existing behavior?

Applying dynamically a warn color is a common use case. Furthermore, since it works with other components, it should also work with this one.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

At least 7.0.4.

Is there anything else we should know?

This behaviour occours because of this (S)CSS-rule here, which applys the color for the icon: https://github.com/angular/material2/blob/9c075f5c50b4d91ad91d4f7fb180f68c5de45cd4/src/lib/menu/_menu-theme.scss#L27-L30

Since the mat-icon does not have a pure color attribute when dynamically assigned, but only an 'ng-reflect-color' attribute, this exclusion rule does not apply and the color rule from above overrides the mat-warn class.

--

A workaround for this bug is to dynamically assign the attribute itself: [attr.color]="(condition) ? 'warn' : 'secondary'".

--

This was already mentioned here: #8594 (comment)

@crisbeto crisbeto self-assigned this Nov 15, 2018
@crisbeto crisbeto added has pr P4 A relatively minor issue that is not relevant to core functions labels Nov 15, 2018
crisbeto added a commit to crisbeto/material2 that referenced this issue Nov 15, 2018
Fixes not being able to set the color of a `mat-icon` inside a `mat-menu-item` dynamically.

Fixes angular#14151.
mmalerba pushed a commit that referenced this issue Dec 4, 2018
Fixes not being able to set the color of a `mat-icon` inside a `mat-menu-item` dynamically.

Fixes #14151.
mmalerba pushed a commit that referenced this issue Dec 10, 2018
Fixes not being able to set the color of a `mat-icon` inside a `mat-menu-item` dynamically.

Fixes #14151.
josephperrott pushed a commit to josephperrott/components that referenced this issue Jan 14, 2019
Fixes not being able to set the color of a `mat-icon` inside a `mat-menu-item` dynamically.

Fixes angular#14151.
@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 Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants