Skip to content

Commit

Permalink
Fixing issue #56
Browse files Browse the repository at this point in the history
Focus behaviour not correct for modal popup
  • Loading branch information
JimBobSquarePants committed Jan 9, 2015
1 parent 8e597d6 commit b4cd15c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
19 changes: 10 additions & 9 deletions build/responsive.js
Expand Up @@ -2012,18 +2012,18 @@
shownEvent = $.Event(eshown),
complete = function () {

$modal.data("currentModal", self.$element);

$modal.focus();
$body.attr({ "tabindex": -1 });
$modal.data("currentModal", self.$element).attr({ "tabindex": 0 }).focus();

// Ensure that focus is maintained within the modal.
$(document).on(efocusin, function (event) {

if (event.target !== $overlay[0] && !$.contains($overlay[0], event.target)) {
var $newTarget = $modal.find("input, select, a, iframe, img, button").first();
$newTarget.length ? $newTarget.focus() : ((!self.options.modal && $close.focus()) || $overlay.focus());
return false;
}
var $newTarget = $modal.find("a, area, button, input, object, select, textarea, [tabindex]").first();
$newTarget.length ? $newTarget.focus() : $modal.focus();

return false;
}
return true;
});

Expand Down Expand Up @@ -2090,8 +2090,9 @@
hiddenEvent = $.Event(ehidden),
complete = function () {
self.destroy(callback);
$modal.removeData("currentModal");
self.$element.trigger(hiddenEvent);
$body.removeAttr("tabindex");
$modal.removeData("currentModal").removeAttr("tabindex");
self.$element.trigger(hiddenEvent).focus();
};

this.$element.trigger(hideEvent);
Expand Down

0 comments on commit b4cd15c

Please sign in to comment.