]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Focus active anchor rather than last one in collection when closing a Reveal modal.
authorMarius Olbertz <marius.olbertz@gmail.com>
Sat, 7 Oct 2017 19:14:03 +0000 (21:14 +0200)
committerMarius Olbertz <marius.olbertz@gmail.com>
Sat, 7 Oct 2017 19:14:03 +0000 (21:14 +0200)
Addresses #10604.

js/foundation.reveal.js

index f430be0da6fe559a970bfb9077d5590ec83ea986..3c8418b4e13eeb5408724fa4b124afcbb7aed841 100644 (file)
@@ -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();
   }
 
   /**