Skip to content

Commit

Permalink
don't refocus document (IE11 bug)
Browse files Browse the repository at this point in the history
  • Loading branch information
samthor committed Feb 14, 2017
1 parent 50c521c commit 1fa2835
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dialog-polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,10 @@
this.overlay = document.createElement('div');
this.overlay.className = '_dialog_overlay';
this.overlay.addEventListener('click', function(e) {
this.forwardTab_ = undefined;
e.stopPropagation();
checkDOM([]); // sanity-check DOM
});
}.bind(this));

this.handleKey_ = this.handleKey_.bind(this);
this.handleFocus_ = this.handleFocus_.bind(this);
Expand Down Expand Up @@ -521,13 +522,15 @@
event.stopPropagation();
safeBlur(/** @type {Element} */ (event.target));

if (this.forwardTab_ === undefined) { return; } // move focus only from a tab key

var dpi = this.pendingDialogStack[0];
var dialog = dpi.dialog;
var position = dialog.compareDocumentPosition(event.target);
if (position & Node.DOCUMENT_POSITION_PRECEDING) {
if (this.forwardTab_) {
dpi.focus_();
} else {
} else if (this.forwardTab_) {
document.documentElement.focus();
}
} else {
Expand Down

0 comments on commit 1fa2835

Please sign in to comment.