Keyboard accessibility – fix enclosed
-
Using Collapse-o-Matic 1.6.3.
The expand/collapse control isn’t accessible by keyboard. I’ve made a couple of quick fixes to resolve that.
First, on the line that reads:
$link = $closeanchor.$anchor.'<'.$tag.' class="collapseomatic '.$trigclass.'" id="'.$id.'" '.$relatt.' '.$altatt.'>'.$startwrap.$title.$endwrap.'</'.$tag.'>';
make it:
$link = $closeanchor.$anchor.'<'.$tag.' tabindex="0" class="collapseomatic '.$trigclass.'" id="'.$id.'" '.$relatt.' '.$altatt.'>'.$startwrap.$title.$endwrap.'</'.$tag.'>';
This will add the control to the keyboard focus order.
Second, the JavaScript needs a shiny new bit. I’ve added this immediately above the “click” handler:
jQuery(document).on('keypress','.collapseomatic', function(event) {
if (event.which == 13) {
event.currentTarget.click();
};
});
This causes the “click” event to fire if the enter key is pressed when the control has focus.
There are probably some other places where fixes are needed — mostly adding tabindex I would imagine — but this does the bare basics. Would be great if it could be integrated into the code.
Matt
The topic ‘Keyboard accessibility – fix enclosed’ is closed to new replies.