Modal: Ignore spurious `focus` event that Firefox fires at `document` when switching back to its tab

Fixes #18365
Refs https://bugzilla.mozilla.org/show_bug.cgi?id=1228802
This commit is contained in:
Chris Rebert 2015-12-22 23:02:57 -07:00
parent 2c69e0f810
commit d12ed5520e
1 changed files with 3 additions and 2 deletions

View File

@ -259,8 +259,9 @@ const Modal = (($) => {
$(document)
.off(Event.FOCUSIN) // guard against infinite focus loop
.on(Event.FOCUSIN, (event) => {
if (this._element !== event.target &&
(!$(this._element).has(event.target).length)) {
if (document !== event.target &&
this._element !== event.target &&
(!$(this._element).has(event.target).length)) {
this._element.focus()
}
})