Skip to content

Commit

Permalink
Added keyboard functionality.
Browse files Browse the repository at this point in the history
I was finding that the default keyboard click no longer worked when there was a parent element with a key-down event. 
So resolved the issue by removing the default behaviour of this click event and replacing it with it's own specified keyboard functionality.
  • Loading branch information
Oliver-ctrlo authored Sep 25, 2023
1 parent 923a034 commit 206060a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/frontend/components/more-less/lib/disclosure-widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,12 @@ const onDisclosureMouseout = function(e) {
}

const setupDisclosureWidgets = function(context) {
$('.trigger[aria-expanded]', context).on('click', onDisclosureClick)
$('.trigger[aria-expanded]', context).on('click keydown', function(ev) {
if (ev.type === 'click' || (ev.type === 'keydown' && (ev.which === 13 || ev.which === 32))) {
ev.preventDefault();
onDisclosureClick.call(this, ev);
}
});

// Also show/hide disclosures on hover for widgets with the data-expand-on-hover attribute set to true
$('.trigger[aria-expanded][data-expand-on-hover=true]', context).on('mouseover', onDisclosureMouseover)
Expand Down

0 comments on commit 206060a

Please sign in to comment.