Bug 1407754 - exiting customize mode quickly after adding a toolbar item to toolbar properly adds it to the toolbar. r?jaws
MozReview-Commit-ID: C7uvVVWoIeB
--- a/browser/components/customizableui/CustomizeMode.jsm
+++ b/browser/components/customizableui/CustomizeMode.jsm
@@ -582,30 +582,43 @@ CustomizeMode.prototype = {
_promiseWidgetAnimationOut(aNode) {
if (!gCosmeticAnimationsEnabled ||
aNode.getAttribute("cui-anchorid") == "nav-bar-overflow-button" ||
(aNode.tagName != "toolbaritem" && aNode.tagName != "toolbarbutton") ||
(aNode.id == "downloads-button" && aNode.hidden)) {
return null;
}
+
let animationNode;
if (aNode.parentNode && aNode.parentNode.id.startsWith("wrapper-")) {
animationNode = aNode.parentNode;
} else {
animationNode = aNode;
}
return new Promise(resolve => {
- animationNode.classList.add("animate-out");
- animationNode.addEventListener("animationend", function cleanupWidgetAnimationEnd(e) {
+ function cleanupCustomizationExit() {
+ resolveAnimationPromise();
+ }
+
+ function cleanupWidgetAnimationEnd(e) {
if (e.animationName == "widget-animate-out" && e.target.id == animationNode.id) {
- animationNode.removeEventListener("animationend", cleanupWidgetAnimationEnd);
- resolve();
+ resolveAnimationPromise();
}
- });
+ }
+
+ function resolveAnimationPromise() {
+ animationNode.removeEventListener("animationend", cleanupWidgetAnimationEnd);
+ animationNode.removeEventListener("customizationending", cleanupCustomizationExit);
+ resolve();
+ }
+
+ animationNode.classList.add("animate-out");
+ animationNode.ownerGlobal.gNavToolbox.addEventListener("customizationending", cleanupCustomizationExit);
+ animationNode.addEventListener("animationend", cleanupWidgetAnimationEnd);
});
},
async addToToolbar(aNode) {
aNode = this._getCustomizableChildForNode(aNode);
if (aNode.localName == "toolbarpaletteitem" && aNode.firstChild) {
aNode = aNode.firstChild;
}