Bug 1349416 - Only delay removeEventListener when hiding after mouseup;r=birtles

The inplace-editor is programmatically hiding the autocomplete-popup
on TAB and notifies the caller. The caller (eg rule view) will trigger
a click on the next focusable element immediately after that.

If the HTMLTooltip is still consuming outside clicks at that point
the click will be swallowed and the new inplace-editor cannot be created.

Depends on D2661

Differential Revision: https://phabricator.services.mozilla.com/D2662

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Julian Descottes 2018-08-03 07:05:51 +00:00
parent f4e6047756
commit 91b9d97d0e

View File

@ -696,15 +696,18 @@ HTMLTooltip.prototype = {
* Hide the current tooltip. The event "hidden" will be fired when the tooltip
* is hidden.
*/
async hide() {
async hide({ fromMouseup = false } = {}) {
this.doc.defaultView.clearTimeout(this.attachEventsTimer);
if (!this.isVisible()) {
this.emit("hidden");
return;
}
// Wait for potential click events before removing listeners.
await new Promise(resolve => this.topWindow.setTimeout(resolve, 0));
// If the tooltip is hidden from a mouseup event, wait for a potential click event
// to be consumed before removing event listeners.
if (fromMouseup) {
await new Promise(resolve => this.topWindow.setTimeout(resolve, 0));
}
this.removeEventListeners();
@ -801,7 +804,7 @@ HTMLTooltip.prototype = {
return;
}
this.hide();
this.hide({ fromMouseup: true });
},
_isInTooltipContainer: function(node) {