From 9be382554d1c51d16a677bbd9b064f175ae79213 Mon Sep 17 00:00:00 2001 From: "Andrea N. Cardona" Date: Sun, 17 Dec 2023 12:18:52 -0800 Subject: [PATCH] Menu button pattern and 4 examples: Set aria-expanded to false when menus are closed (pull #2839) Closes issues #697 and #2834 with the following changes: * Revise menu button pattern to specify that aria-expanded is set to false when the menu is not displayed. * Revise JS and documentation for 3 menu button examples and the toolbar example to set aria-expanded false when their menus are closed. * Adjusts corresponding regression tests to ensure the state of expanded is true when the menus are open and false when the menus are closed. --------- Co-authored-by: Matt King --- .../menu-button-actions-active-descendant.js | 4 +-- .../examples/js/menu-button-actions.js | 2 +- .../examples/js/menu-button-links.js | 2 +- ...menu-button-actions-active-descendant.html | 34 ++++++++----------- .../examples/menu-button-actions.html | 32 ++++++++--------- .../examples/menu-button-links.html | 30 +++++++--------- .../menu-button/menu-button-pattern.html | 3 +- .../patterns/toolbar/examples/js/FontMenu.js | 2 +- .../patterns/toolbar/examples/toolbar.html | 22 +++++------- .../menu-button_actions-active-descendant.js | 4 +-- test/tests/menu-button_actions.js | 4 +-- test/tests/menu-button_links.js | 4 +-- test/tests/toolbar_toolbar.js | 19 ++++++++--- 13 files changed, 78 insertions(+), 84 deletions(-) diff --git a/content/patterns/menu-button/examples/js/menu-button-actions-active-descendant.js b/content/patterns/menu-button/examples/js/menu-button-actions-active-descendant.js index 35472f1e00..a1165150d5 100644 --- a/content/patterns/menu-button/examples/js/menu-button-actions-active-descendant.js +++ b/content/patterns/menu-button/examples/js/menu-button-actions-active-descendant.js @@ -162,9 +162,9 @@ class MenuButtonActionsActiveDescendant { closePopup() { if (this.isOpen()) { - this.buttonNode.removeAttribute('aria-expanded'); + this.buttonNode.setAttribute('aria-expanded', 'false'); this.menuNode.setAttribute('aria-activedescendant', ''); - for (var i = 0; i < this.menuitemNodes.length; i++) { + for (let i = 0; i < this.menuitemNodes.length; i++) { this.menuitemNodes[i].classList.remove('focus'); } this.menuNode.style.display = 'none'; diff --git a/content/patterns/menu-button/examples/js/menu-button-actions.js b/content/patterns/menu-button/examples/js/menu-button-actions.js index 7f81486f5f..cd69d5621f 100644 --- a/content/patterns/menu-button/examples/js/menu-button-actions.js +++ b/content/patterns/menu-button/examples/js/menu-button-actions.js @@ -156,7 +156,7 @@ class MenuButtonActions { closePopup() { if (this.isOpen()) { - this.buttonNode.removeAttribute('aria-expanded'); + this.buttonNode.setAttribute('aria-expanded', 'false'); this.menuNode.style.display = 'none'; } } diff --git a/content/patterns/menu-button/examples/js/menu-button-links.js b/content/patterns/menu-button/examples/js/menu-button-links.js index 90f4146da1..757aac2268 100644 --- a/content/patterns/menu-button/examples/js/menu-button-links.js +++ b/content/patterns/menu-button/examples/js/menu-button-links.js @@ -153,7 +153,7 @@ class MenuButtonLinks { closePopup() { if (this.isOpen()) { - this.buttonNode.removeAttribute('aria-expanded'); + this.buttonNode.setAttribute('aria-expanded', 'false'); this.menuNode.style.display = 'none'; } } diff --git a/content/patterns/menu-button/examples/menu-button-actions-active-descendant.html b/content/patterns/menu-button/examples/menu-button-actions-active-descendant.html index 3a3076574b..1fbd72bbcd 100644 --- a/content/patterns/menu-button/examples/menu-button-actions-active-descendant.html +++ b/content/patterns/menu-button/examples/menu-button-actions-active-descendant.html @@ -52,7 +52,7 @@

Example