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

Menu: label as HTML (escape false) is rendered in aria-label property of the menuitem #15467

Open
alaindeurveilher opened this issue May 6, 2024 · 1 comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@alaindeurveilher
Copy link

Describe the bug

When the label of a MenuItem is defined as HTML string, the same html is currently used as the value for the aria-label property.
Currently, MenuItem does not have an explicit ariaLabel property, but it's implicitely filled with [attr.aria-label]="label(item.label)" which in the case of html content with the use of escape: false does not provide the intended markups, and makes testing difficult to query the element.

Environment

Windows

Reproducer

No response

Angular version

17.3.0

PrimeNG version

17.13.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.11.0

Browser(s)

Chrome

Steps to reproduce the behavior

items: MenuItem[] = [
  {
    label: `
      <div class="flex align-items-center">
        <i class="pi pi-home"></i>
        <span>Home</span>
      </div>`,
    escape: false,
    routerLink="/",
  },
];

The rendered HTML is something like:

<li role="menuitem" class="p-element p-menuitem"  aria-label="
    <div class=&quot;flex align-items-center&quot;>
      <i class=&quot;pi pi-home&quot;></i>
      <span>Home</span>
    </div>">
  <div class="p-menuitem-content">
    <a  ng-reflect-router-link="/" href="http://localhost:4200/">
      <span class="p-menuitem-text">
        <div class="flex align-items-center">
          <i class="pi pi-home"></i>
          <span>Home</span>
        </div>
      </span>
    </div>
</li>

Expected behavior

The aria-label property of the role menuitem element should be a plain text.

@alaindeurveilher alaindeurveilher added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label May 6, 2024
@jayee
Copy link

jayee commented May 14, 2024

Yes, this behaviour is totally wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

2 participants