Skip to content

Commit

Permalink
Make autofocus element in featherlight focus [#259]
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Nov 16, 2016
1 parent c74ef77 commit c6ebe69
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Featherlight – Changelog
Master
-----------------------------------
- Changed close icon to a <button>. Be sure to use current CSS files too. [#260]
- Improved focus handling [#259]

1.5.0 - 2016-06-27
-----------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/featherlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@

afterContent: function(_super, event){
var r = _super(event);
this.$instance.find('[autofocus]:not([disabled])').focus();
this.onResize(event);
return r;
}
Expand Down
8 changes: 7 additions & 1 deletion test/featherlight_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,13 @@ var stubAjaxLoad = function(content) {
$.featherlight.close();
expect($(document.activeElement)).to.have.class('for-focus');
expect($('.for-focus')).not.to.have.attr('tabindex');
})
});

it('focussed on "autofocus" content, if any', function() {
$.featherlight({html: '<input><input autofocus class="ok">'});
expect($(document.activeElement)).to.have.class('ok');
$.featherlight.close();
});
});
});
}(jQuery));

0 comments on commit c6ebe69

Please sign in to comment.