Skip to content

Commit

Permalink
Fix: a11y for ColumnHider button
Browse files Browse the repository at this point in the history
* set role="button" and tabindex="0" on DOM node
* add keydown handler for enter and space on node to toggle menu

Fixes SitePen#1426
  • Loading branch information
msssk committed Apr 3, 2020
1 parent 2ebf9b7 commit c13e78a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion extensions/ColumnHider.js
Expand Up @@ -150,7 +150,8 @@ define([
hiderToggleNode = this.hiderToggleNode = domConstruct.create('div', {
'aria-label': this.i18nColumnHider.popupTriggerLabel,
className: 'ui-icon dgrid-hider-toggle',
type: 'button'
role: 'button',
tabindex: 0
}, this.domNode);

// The ColumnHider icon is 16 x 16 pixels. Presumably, when it was created that size worked in all
Expand All @@ -168,6 +169,13 @@ define([
grid._toggleColumnHiderMenu(e);
}));

this._listeners.push(listen(hiderToggleNode, 'keydown', function (event) {
var charOrCode = event.charCode || event.keyCode;
if (charOrCode === /*ENTER*/ 13 || charOrCode === /*SPACE*/ 32) {
grid._toggleColumnHiderMenu(event);
}
}));

// Create the column list, with checkboxes.
hiderMenuNode = this.hiderMenuNode = domConstruct.create('div', {
'aria-label': this.i18nColumnHider.popupLabel,
Expand Down

0 comments on commit c13e78a

Please sign in to comment.