Sha256: 755b03753af3ddd19cd7b6098850674c956a5b1841eafc788f2f36bba2fc4045

Contents?: true

Size: 1.38 KB

Versions: 21

Compression:

Stored size: 1.38 KB

Contents

/* eslint-disable require-jsdoc */

// This will apply some fixes for the Foundation dropdown menu element
// according to W3C instructions at:
// https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-links.html
//
// NOTE:
// This needs to run AFTER Foundation has been initialized because those
// initializers will affect the drop down menu elements.
export default function fixDropdownMenus() {
  $("[data-dropdown-menu]").each((_i, element) => {
    // This will break navigation on macOS VoiceOver app since it will let the
    // user to focus on the li element instead of the <a> element where we
    // actually need the focus to be in.
    $("li.is-dropdown-submenu-parent", element).removeAttr("aria-haspopup").removeAttr("aria-label");
    $("li.is-dropdown-submenu-parent > a:first", element).removeAttr("aria-label");
    // Foundation marks the wrong role for the submenu elements
    $("ul.is-dropdown-submenu", element).attr("role", "menu");
  })
}

// Ensure the first element is always focused when a dropdown is opened as
// this would not always happen when using a screen reader. If this is not
// done, the screen reader will stay quiet when the menu opens which can lead
// to the blind user not understanding the menu has opened.
$(() => {
  $("[data-dropdown-menu]").on("show.zf.dropdownMenu", (_i, element) => {
    $("li:first > a", element).focus();
  });
})

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.8 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.7 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.6 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.10 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.9 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.5 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.8 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.4 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.3 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.7 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.5 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.2 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.1 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.4 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.0 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.3 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.0.rc2 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.27.0.rc1 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.2 app/packs/src/decidim/dropdowns_menus.js