Skip to content

Commit

Permalink
Layout Grid Examples: Fix NUX close button for IE (pull #548)
Browse files Browse the repository at this point in the history
Fix issue #531: NUX instructions not closing as expected with IE11.

A loop was created on focus,
where the instructions were displayed and then dismissing the instructions set focus to the element that displayed the instructions on focus.
This happened because the once option was used for the event listener, which is not supported in IE11.

This commit adds an event listener that, when fired, removed the event listener and setup the instructions and close listeners/ handlers.
  • Loading branch information
gerardkcohen authored and mcking65 committed Nov 29, 2017
1 parent 9a1ea48 commit a1de1af
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions examples/grid/js/layoutGrids.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,31 +35,24 @@ window.addEventListener('load', function () {

var gridNUX = document.getElementById('grid-nux');
var firstGridCell = document.querySelector('#ex1 [tabindex="0"]');
firstGridCell.addEventListener(
'focus',
function () {
aria.Utils.removeClass(gridNUX, 'hidden');
},
{
once: true
}
);

var NUXclose = document.getElementById('close-nux-button');
var closeNUX = function () {
aria.Utils.addClass(gridNUX, 'hidden');
try {
firstGridCell.focus();
}
catch (error) { }
firstGridCell.focus();
};
NUXclose.addEventListener('click', closeNUX);
NUXclose.addEventListener('keyup', function (event) {
var key = event.which || event.keyCode;
if (key === aria.KeyCode.RETURN) {
closeNUX();
}
});
var setupInstructions = function () {
firstGridCell.removeEventListener('focus', setupInstructions);
aria.Utils.removeClass(gridNUX, 'hidden');

NUXclose.addEventListener('click', closeNUX);
NUXclose.addEventListener('keyup', function (event) {
if (event.which === aria.KeyCode.RETURN) {
closeNUX();
}
});
};

firstGridCell.addEventListener('focus', setupInstructions);
});

function PillList (grid, input, submitButton, formUpdateText) {
Expand Down

0 comments on commit a1de1af

Please sign in to comment.