From: Marius Olbertz Date: Tue, 1 Dec 2015 19:58:37 +0000 (+0100) Subject: Focus is now shifted back to the anchor when modal is closed using the keyboard. X-Git-Tag: v6.0.5~15^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7341%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Focus is now shifted back to the anchor when modal is closed using the keyboard. --- diff --git a/js/foundation.reveal.js b/js/foundation.reveal.js index c0db5ed31..c86d24bcc 100644 --- a/js/foundation.reveal.js +++ b/js/foundation.reveal.js @@ -332,6 +332,7 @@ close: function() { if (this.options.closeOnEsc) { this.close(); + this.$anchor.focus(); } } }); @@ -359,13 +360,18 @@ } }, open: function() { - if ($target.is(_this.focusableElements)) { // dont't trigger if acual element has focus (i.e. inputs, links, ...) + if (_this.$element.find(':focus').is(_this.$element.find('[data-close]'))) { + setTimeout(function() { // set focus back to anchor if close button has been activated + _this.$anchor.focus(); + }, 1); + } else if ($target.is(_this.focusableElements)) { // dont't trigger if acual element has focus (i.e. inputs, links, ...) this.open(); } }, close: function() { if (this.options.closeOnEsc) { this.close(); + this.$anchor.focus(); } } });