Skip to content

Commit

Permalink
Handle case when no tabbable element exists
Browse files Browse the repository at this point in the history
  • Loading branch information
evoyy committed Mar 25, 2016
1 parent 1a0a069 commit 471ef4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/helpers/scopeTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var findTabbable = require('../helpers/tabbable');

module.exports = function(node, event) {
var tabbable = findTabbable(node);
if (!tabbable.length) return;
var finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1];
var leavingFinalTabbable = (
finalTabbable === document.activeElement ||
Expand Down
8 changes: 8 additions & 0 deletions specs/Modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ describe('Modal', function () {
});
});

it('handles case when child has no tabbable elements', function() {
var component = renderModal({isOpen: true}, 'hello');
assert.doesNotThrow(function() {
Simulate.keyDown(component.portal.refs.content, {key: "Tab", keyCode: 9, which: 9})
});
unmountModal();
});

it('supports custom className', function() {
var modal = renderModal({isOpen: true, className: 'myClass'});
equal(modal.portal.refs.content.className.contains('myClass'), true);
Expand Down

0 comments on commit 471ef4c

Please sign in to comment.