Skip to content

Commit

Permalink
LIB-111 Accordion: link 'button' keyboard accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmcd75 committed Mar 14, 2024
1 parent cb515a5 commit 0577335
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions custom/modules/lib_core/js/accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,21 @@ Array.prototype.slice.call(document.querySelectorAll('.Accordion')).forEach(func

var isExpanded = target.getAttribute('aria-expanded') == 'true';
var allowToggle = (allowMultiple) ? allowMultiple : accordion.hasAttribute('data-allow-toggle');
var isLinkButton = target.hasAttribute('onclick');

// 33 = Page Up, 34 = Page Down
var ctrlModifier = (event.ctrlKey && key.match(/33|34/));

// Is this coming from an accordion header?
if (target.classList.contains('Accordion-trigger')) {
// Accessibility: enable space key activation on re: link button
if (isLinkButton && key.match(/32/)) {
var index = triggers.indexOf(target);
triggers[index].click();
// Prevent default browser scroll down behaviour from spacebar
event.preventDefault();
}

// Up/ Down arrow and Control + Page Up/ Page Down keyboard operations
// 38 = Up, 40 = Down
if (key.match(/37|38|39|40/) || ctrlModifier) {
Expand Down

0 comments on commit 0577335

Please sign in to comment.