Sha256: 9866d535f03834f9fbfd91706aeea901c80cc33b374f657ecce0cb2ef94d27a9

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 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");
    // 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

10 entries across 10 versions & 1 rubygems

Version Path
decidim-core-0.26.0 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.0.rc2 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.26.0.rc1 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.25.2 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.25.1 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.25.0 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.25.0.rc4 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.25.0.rc3 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.25.0.rc2 app/packs/src/decidim/dropdowns_menus.js
decidim-core-0.25.0.rc1 app/packs/src/decidim/dropdowns_menus.js