From 15d7156ef4d8d3c8dc56bbf6582796eeca6e83dd Mon Sep 17 00:00:00 2001 From: Marius Olbertz Date: Tue, 1 Dec 2015 20:58:37 +0100 Subject: [PATCH] Focus is now shifted back to the anchor when modal is closed using the keyboard. --- js/foundation.reveal.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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(); } } }); -- 2.47.2