components icon indicating copy to clipboard operation
components copied to clipboard

bug(COMPONENT): MAT-ICON exhibits different behaviors when the fontSet is

Open KMaster90 opened this issue 2 years ago • 5 comments

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

No response

Description

With the default icon fontSet I can use <mat-icon fontIcon=icon_name/>

but if I change all the icons to outlined using
iconRegistry.setDefaultFontSetClass('material-icons-outlined'); or if I use it on a specific Icon fontSet="material-icons-outlined"

<mat-icon fontIcon=icon_name/> DOESN'T WORK

I HAVE TO USE <mat-icon>icon_name</mat-icon> TO LET IT WORK NOW

(so the problem is to change all the icons when the app is already done)

Reproduction

StackBlitz link: Steps to reproduce: 1. 2.

Expected Behavior

<mat-icon fontIcon=icon_name fontSet="material-icons-outlined"/> HAS TO WORK

Actual Behavior

<mat-icon fontIcon=icon_name fontSet="material-icons-outlined"/> DOESN'T WORK

Environment

  • Angular: 17.1
  • CDK/Material: 17.1
  • Browser(s): arc
  • Operating System (e.g. Windows, macOS, Ubuntu): mac

KMaster90 avatar Feb 05 '24 12:02 KMaster90

Hello @KMaster90 ,

I believe the expected behavior is that setDefaultFontSetClass only afects <mat-icon> when it uses fontSet input.

  /**
   * Sets the CSS classes to be used for icon fonts when an `<mat-icon>` component does not
   * have a fontSet input value, and is not loading an icon by name or URL.
   */
  setDefaultFontSetClass(...classNames: string[]): this {
    this._defaultFontSetClass = classNames;
    return this;
  }

We generally ask issue reports to have Stackblitz reproduction. If you think there could be an improvement, I suggest starting a discussion or creating a feature request.

Expected Behavior HAS TO WORK

Actual Behavior DOESN'T WORK

If you would like support, I suggest using the support channels, which are StackOverflow, Gitter, and Google Groups. We can give a limited amount of support in this issue tracker.

Best Regards,

Zach

zarend avatar Feb 05 '24 18:02 zarend

STACKBLITZ: StackBlitz-Bug_Example

THIS IMAGE SHOWS 1 ICON INSTEAD OF 2 image

image

Thank you for your prompt response, anyway, it is evident from the stackblitz and the pictures that if I change the fontSet for the component providers: [{ provide: MAT_ICON_DEFAULT_OPTIONS, useValue: { fontSet: 'material-icons-outlined' }, }], then <mat-icon>home</mat-icon> this format works <mat-icon fontIcon="home" /> this format doesn't work

It seems more a bug than a feature, am I wrong?

Thank you, Paolo

KMaster90 avatar Feb 05 '24 22:02 KMaster90

Same issue,marked!

<mat-icon fontSet="material-icons-outlined">person</mat-icon> works. <mat-icon fontIcon="person" fontSet="material-icons-outlined"></mat-icon> not work!

niltor avatar Feb 20 '24 08:02 niltor

i experienced the same issue, is there any plan to fix this?

Hiwados avatar Jul 29 '24 10:07 Hiwados

I am experiencing similar issue .. see stackblitz @mmalerba

neildeighan avatar Aug 22 '24 12:08 neildeighan