Bug 605365 - Hide form assistant when focused element is blurred (r=mfinkle)

This commit is contained in:
Lucas Rocha 2011-09-19 09:46:11 -07:00
parent ad387e37bc
commit 1634ce0ddf

View File

@ -77,6 +77,7 @@ function FormAssistant() {
addEventListener("keypress", this, true);
addEventListener("keyup", this, false);
addEventListener("focus", this, true);
addEventListener("blur", this, true);
addEventListener("pageshow", this, false);
addEventListener("pagehide", this, false);
addEventListener("submit", this, false);
@ -354,6 +355,19 @@ FormAssistant.prototype = {
this.currentIndex = focusedIndex;
break;
case "blur":
content.setTimeout(function(self) {
if (!self._open)
return;
// If the blurring causes focus be in no other element,
// we should close the form assistant.
let focusedElement = gFocusManager.getFocusedElementForWindow(content, true, {});
if (!focusedElement)
self.close();
}, 0, this);
break;
case "text":
if (this._isValidatable(aEvent.target))
sendAsyncMessage("FormAssist:ValidationMessage", this._getJSON());