Skip to content

feat(badge): Badge should warn when used on an aria-hidden mat-icon #27035

Closed
@jelbourn

Description

@jelbourn

Feature Description

From usages across Google, we've seen that's it's common for devs to put matBadge on <mat-icon>. The problem is that <mat-icon> is aria-hidden by default, meaning that the badge content is also invisible to screen readers. Our documentation already calls this out as a misuse of the badge, but we can go a step further and actually produce a console warning. This would look something roughly like

if (ngDevMode && host.nodeName === 'mat-icon' && host.getAttribute('aria-hidden') === 'true') {
  console.warn('Warning: detected matBadge on a "<mat-icon>" with "aria-hidden="true"\n${host.outerHTML}');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/badgefeatureThis issue represents a new feature or feature request rather than a bug or bug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions