Skip to content

Commit

Permalink
Fix focus not returned correctly when active element is the lightbox …
Browse files Browse the repository at this point in the history
…root element
  • Loading branch information
jsor committed Nov 21, 2016
1 parent 1c45f89 commit b4945c5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/lity.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Lity - v2.2.0 - 2016-10-08
/*! Lity - v2.2.0 - 2016-11-21
* http://sorgalla.com/lity/
* Copyright (c) 2015-2016 Jan Sorgalla; Licensed MIT */
.lity {
Expand Down
10 changes: 8 additions & 2 deletions dist/lity.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! Lity - v2.2.0 - 2016-10-08
/*! Lity - v2.2.0 - 2016-11-21
* http://sorgalla.com/lity/
* Copyright (c) 2015-2016 Jan Sorgalla; Licensed MIT */
(function(window, factory) {
Expand Down Expand Up @@ -511,7 +511,13 @@
var deferred = _deferred();

// We return focus only if the current focus is inside this instance
if (activeElement && $.contains(element[0], document.activeElement)) {
if (
activeElement &&
(
document.activeElement === element[0] ||
$.contains(element[0], document.activeElement)
)
) {
activeElement.focus();
}

Expand Down
2 changes: 1 addition & 1 deletion dist/lity.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/lity.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/lity.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,13 @@
var deferred = _deferred();

// We return focus only if the current focus is inside this instance
if (activeElement && $.contains(element[0], document.activeElement)) {
if (
activeElement &&
(
document.activeElement === element[0] ||
$.contains(element[0], document.activeElement)
)
) {
activeElement.focus();
}

Expand Down

0 comments on commit b4945c5

Please sign in to comment.