angular / components

Component infrastructure and Material Design components for Angular
https://material.angular.io
MIT License
24.35k stars 6.74k forks source link

bug(MatBadge/MatIcon): Number not showing in badge when used with icon, using custom theme #28642

Closed neildeighan closed 8 months ago

neildeighan commented 8 months ago

Is this a regression?

The previous version in which this bug was not present was

Unknown

Description

Implementing a simple mat-icon with a matBadge="5", the number 5 is not shown in badge, it works ok when using one of the pre-defined themes i.e. Deep Purple & Amber, but when I select custom theme on adding angular/material, without changing the default colors, the number is not shown.

Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-adgwky?file=src%2Fmain.ts Steps to reproduce:

  1. ng new test-app (scss)
  2. ng add @angular/material ... ? Choose a prebuilt theme name, or "custom" for a custom theme: Custom ? Set up global Angular Material typography styles? Yes ? Include the Angular animations module? Include and enable animations 3) imported MatIconModule & MatBadgeModule into app.component.ts 4) Copied & pasted same code from https://material.angular.io/components/badge/examples (ts/html/css) to app.*

Expected Behavior

number is shown in badge when applied to mat-icon

Actual Behavior

badge is "blank"

Environment

crisbeto commented 8 months ago

It looks like we forgot to update the template for our custom themes. You should change the $demo-theme to this:

$demo-theme: mat.define-light-theme((
  color: (
    primary: $demo-primary,
    accent: $demo-accent,
    warn: $demo-warn,
  ),
  typography: mat.define-typography-config(),
  density: 0,
));

I've sent a fix for our own code.

angular-automatic-lock-bot[bot] commented 7 months ago

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.