diff --git a/themes/bootstrap/js/lightbox.js b/themes/bootstrap/js/lightbox.js index b44dfa53037e53e732c7e654f230917bcdfe48ee..dad90f1e54ee0cb875b3f9bc935bae0f92b85a49 100644 --- a/themes/bootstrap/js/lightbox.js +++ b/themes/bootstrap/js/lightbox.js @@ -388,6 +388,10 @@ var Lightbox = { * We do it here so that non-JS users still have a good time. */ $(document).ready(function() { + // save the currently-focused element + $('#modal').on('show', function(e) { + Lightbox.focusFrom = document.activeElement; + }); // Add handlers to the forms Lightbox.addOpenAction(Lightbox.registerForms); /** @@ -396,6 +400,10 @@ $(document).ready(function() { * Yes, the secret's out, our beloved Lightbox is a modal */ $('#modal').on('hidden', Lightbox.closeActions); + // refocus the previously-focused element + $('#modal').on('hidden', function(e) { + Lightbox.focusFrom.focus(); + }); /** * If a link with the class .modal-link triggers the lightbox, * look for a title="" to use as our lightbox title. @@ -407,4 +415,4 @@ $(document).ready(function() { } $('#modal .modal-header h3').html(title); }); -}); \ No newline at end of file +}); diff --git a/themes/bootstrap/templates/layout/layout.phtml b/themes/bootstrap/templates/layout/layout.phtml index c75580fe8c182a256661adf4b4505ef9664cb697..569380385ccd0176c6bb005fece7fe4b66db6dbb 100644 --- a/themes/bootstrap/templates/layout/layout.phtml +++ b/themes/bootstrap/templates/layout/layout.phtml @@ -121,7 +121,7 @@ </div> </div> <!-- MODAL IN CASE WE NEED ONE --> - <div id="modal" class="modal hide fade"> + <div id="modal" class="modal hide fade" tabindex="-1"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h3></h3>