Skip to content

Commit 1fdce6a

Browse files
authored
feat(ui5-menu): аdd aria-expanded attribute to menuItem with submenu (#11754)
1 parent 0012d36 commit 1fdce6a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

packages/main/cypress/specs/Menu.cy.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,15 @@ describe("Menu interaction", () => {
502502
.shadow()
503503
.find("li")
504504
.should("have.attr", "role", "menuitem")
505-
.and("have.attr", "aria-haspopup", "menu");
505+
.and("have.attr", "aria-haspopup", "menu")
506+
.and("have.attr", "aria-expanded", "false");
507+
508+
cy.get("@items")
509+
.eq(0)
510+
.ui5MenuItemClick()
511+
.shadow()
512+
.find("li")
513+
.should("have.attr", "aria-expanded", "true");
506514

507515
cy.get("@items")
508516
.eq(1)

packages/main/src/MenuItem.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,13 @@ class MenuItem extends ListItem implements IMenuItem {
385385
role: AriaRole;
386386
ariaHaspopup?: `${AriaHasPopup}`;
387387
ariaKeyShortcuts?: string;
388+
ariaExpanded?: boolean;
388389
ariaHidden?: boolean;
389390
} = {
390391
role: this.accessibilityAttributes.role || "menuitem",
391392
ariaHaspopup: this.hasSubmenu ? "menu" : undefined,
392393
ariaKeyShortcuts: this.accessibilityAttributes.ariaKeyShortcuts,
394+
ariaExpanded: this.hasSubmenu ? this.isSubMenuOpen : undefined,
393395
ariaHidden: !!this.additionalText && !!this.accessibilityAttributes.ariaKeyShortcuts ? true : undefined,
394396
};
395397

0 commit comments

Comments
 (0)