Bug 1713259, hide form validation popup when switching pages, r=Gijs

Differential Revision: https://phabricator.services.mozilla.com/D116375
This commit is contained in:
Neil Deakin 2021-06-03 13:18:41 +00:00
parent 15e76ffa7e
commit d0aae5dbdc

View File

@ -37,6 +37,11 @@ class FormValidationChild extends JSWindowActorChild {
this._hidePopup();
}
break;
case "pagehide":
// Act as if the element is being blurred. This will remove any
// listeners and hide the popup.
this._onBlur();
break;
case "input":
this._onInput(aEvent);
break;
@ -129,10 +134,12 @@ class FormValidationChild extends JSWindowActorChild {
* hide the popup.
*/
_onBlur(aEvent) {
aEvent.originalTarget.removeEventListener("input", this);
aEvent.originalTarget.removeEventListener("blur", this);
this._element = null;
if (this._element) {
this._element.removeEventListener("input", this);
this._element.removeEventListener("blur", this);
}
this._hidePopup();
this._element = null;
}
/*
@ -159,10 +166,17 @@ class FormValidationChild extends JSWindowActorChild {
panelData.position = "after_start";
}
this.sendAsyncMessage("FormValidation:ShowPopup", panelData);
aElement.ownerGlobal.addEventListener("pagehide", this, {
mozSystemGroup: true,
});
}
_hidePopup() {
this.sendAsyncMessage("FormValidation:HidePopup", {});
this._element.ownerGlobal.removeEventListener("pagehide", this, {
mozSystemGroup: true,
});
}
_isRootDocumentEvent(aEvent) {