Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
cpoppema committed Oct 1, 2017
1 parent 2b99d2c commit 0584b5f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion code/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@
function autofocus() {
var elem = $('[autofocus]:visible');
if (elem && inViewport(elem.get(0))) {
$(elem).focus();
// do a little dance to grab attention because this doesn't always
// *immediately* work, add a delay for it:
// $(elem).focus();
// https://bugzilla.mozilla.org/show_bug.cgi?id=1324255
setTimeout(function setFocusFirst() {
$(elem).focus();
}, 100);
var secondTimeout = setTimeout(function setFocusSecond() {
$(elem).focus();
}, 150);
$(window).one('focus', function() {
// cancel second try when window has focus
clearTimeout(secondTimeout);
});
}
}

Expand Down

0 comments on commit 0584b5f

Please sign in to comment.