From 9fce99e34709e5ec5a2dc1e0ac98e5f1e8c6af84 Mon Sep 17 00:00:00 2001 From: Marius Olbertz Date: Sat, 7 Oct 2017 21:14:03 +0200 Subject: [PATCH] Focus active anchor rather than last one in collection when closing a Reveal modal. Addresses #10604. --- js/foundation.reveal.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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(); } /** -- 2.47.3