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

matBadge changes position after content is updated #16992

Closed
domsew opened this issue Sep 6, 2019 · 8 comments · Fixed by #22169
Closed

matBadge changes position after content is updated #16992

domsew opened this issue Sep 6, 2019 · 8 comments · Fixed by #22169
Labels
area: material/badge P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects

Comments

@domsew
Copy link

domsew commented Sep 6, 2019

Reproduction

https://stackblitz.com/edit/angular-f2fovj

  1. Wait 5 s, and see effect.

Expected Behavior

MatBadge should preserve its position after content is updated

Actual Behavior

MatBadge changes position after content is updated.

Environment

  • Angular:
  • CDK/Material:
  • Browser(s): Chrome (latest)
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows 10
    image
@domsew
Copy link
Author

domsew commented Sep 6, 2019

Ok, the solution for this problem is not to use matBadge with inline elements.

@guillaumebouhier
Copy link

Is it supposed to be fixed or is it a limitation ?
I have strange behaviors too using badges with h1, h2 tags. The badge is moved to the right end of the page.

Regards

@chathura90
Copy link

I found a hack for this issue
Use <mat-icon></mat-icon>
eg:
<mat-icon class="badge-icon" [matBadge]="data.responses?.length" matBadgePosition="above after" matBadgeOverlap="false" matBadgeSize="small" [matBadgeHidden]="data.responses.length < 1"></mat-icon>

@ctbolton
Copy link

You can also just add "display: inline-block;" to the inline element instead of using mat-icon around it.

@mmalerba mmalerba added the needs triage This issue needs to be triaged by the team label May 20, 2020
@crisbeto crisbeto added area: material/badge P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels May 25, 2020
@crisbeto crisbeto added this to Triaged in triage #1 via automation May 25, 2020
@AdrianDC
Copy link

Also affected with an Angular 10 (CLI 10.2.0, Material 10.2.7) application using a mat-checkbox inside a table header cell.

Worked around through the mat-icon as such :

        <th mat-header-cell *matHeaderCellDef>
          <mat-checkbox
             ...
-            [matBadgeColor]="items.length === 0 ? 'warn' : 'primary'"
-            [matBadge]="items.length"
           ></mat-checkbox>
+          <mat-icon
+            class="mat-checkbox-icon-badge"
+            [matBadgeColor]="items.length === 0 ? 'warn' : 'primary'"
+            [matBadge]="items.length"
+            matBadgePosition="above after"
+            matBadgeOverlap="true"
+          ></mat-icon>
         </th>
+.mat-checkbox-icon-badge {
+  height: 0px;
+  width: 0px;
+
+  .mat-badge-content {
+    right: -14px;
+    top: -25px;
+  }
+}

@blogcraft
Copy link

I use Font Awesome instead of Angular Icons and have the same issue. (I won't use Material Icons because they suck 😋)

@whisher
Copy link

whisher commented Mar 4, 2021

Any news? :)

@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 Apr 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/badge P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
No open projects
triage #1
  
Triaged
Development

Successfully merging a pull request may close this issue.

9 participants