Skip to content

Commit

Permalink
fixed the issue (#8721)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoo-msft authored Oct 26, 2023
1 parent a0fe574 commit 0f0a19a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
2 changes: 2 additions & 0 deletions source/nodejs/adaptivecards/src/card-elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6644,11 +6644,13 @@ class OverflowAction extends Action {
}

contextMenu.onClose = () => {
this.renderedElement?.focus();
this.renderedElement?.setAttribute("aria-expanded", "false");
}

this.renderedElement.setAttribute("aria-expanded", "true");
contextMenu.popup(this.renderedElement);
contextMenu.selectedIndex = 0;
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/nodejs/adaptivecards/src/controls/menu-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export class MenuItem {
};
this._element.onkeydown = (e) => {
if (e.key === Constants.keys.enter) {
e.cancelBubble = true;

e.stopPropagation();
e.preventDefault();
this.click();
}
};
Expand Down
17 changes: 17 additions & 0 deletions source/nodejs/adaptivecards/src/controls/popup-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export class PopupMenu extends PopupControl {

element.appendChild(renderedItem);

if (i == 0)
{
renderedItem.setAttribute("aria-expanded", "true");
}

if (i === this.selectedIndex) {
renderedItem.focus();
}
Expand Down Expand Up @@ -63,6 +68,7 @@ export class PopupMenu extends PopupControl {
}

this.selectedIndex = selectedItemIndex;
this.removeAriaExpanded(selectedItemIndex);

e.cancelBubble = true;

Expand All @@ -76,6 +82,7 @@ export class PopupMenu extends PopupControl {
if (selectedItemIndex >= this._renderedItems.length) {
selectedItemIndex = 0;
}
this.removeAriaExpanded(selectedItemIndex);
}

this.selectedIndex = selectedItemIndex;
Expand All @@ -101,4 +108,14 @@ export class PopupMenu extends PopupControl {
this._selectedIndex = index;
}
}

// remove aria-expanded attribute from menu item
private removeAriaExpanded(index: number) {
if (this._renderedItems[index].getAttribute("aria-expanded") === "true") {
this._renderedItems[index].removeAttribute("aria-expanded");
}
}



}

0 comments on commit 0f0a19a

Please sign in to comment.