From: Marius Olbertz Date: Sat, 7 Oct 2017 19:14:03 +0000 (+0200) Subject: Focus active anchor rather than last one in collection when closing a Reveal modal. X-Git-Tag: v6.6.0~3^2~335^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fce99e34;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Focus active anchor rather than last one in collection when closing a Reveal modal. Addresses #10604. --- diff --git a/js/foundation.reveal.js b/js/foundation.reveal.js index f430be0da..3c8418b4e 100644 --- a/js/foundation.reveal.js +++ b/js/foundation.reveal.js @@ -228,6 +228,9 @@ class Reveal extends Plugin { } } + // Remember anchor that opened it to set focus back later, have general anchors as fallback + this.$activeAnchor = $(document.activeElement).is(this.$anchor) ? $(document.activeElement) : this.$anchor; + this.isActive = true; // Make elements invisible, but remove display: none so we can get size and positioning @@ -432,7 +435,7 @@ class Reveal extends Plugin { } } - this.$anchor.focus(); + this.$activeAnchor.focus(); } /**