]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Focus is now shifted back to the anchor when modal is closed using the keyboard. 7341/head
authorMarius Olbertz <marius.olbertz@gmail.com>
Tue, 1 Dec 2015 19:58:37 +0000 (20:58 +0100)
committerMarius Olbertz <marius.olbertz@gmail.com>
Tue, 1 Dec 2015 19:58:37 +0000 (20:58 +0100)
js/foundation.reveal.js

index c0db5ed316597a0290341781d524bf762efcd4d4..c86d24bcc58221003dbca8289e50002c7cc9bed5 100644 (file)
           close: function() {
             if (this.options.closeOnEsc) {
               this.close();
+              this.$anchor.focus();
             }
           }
         });
           }
         },
         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();
           }
         }
       });