Bug 1392081 - Reset the Places toolbar view when the toolbar is collapsed. r=gijs
MozReview-Commit-ID: IFOxCnslZRX
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1197,34 +1197,53 @@ var PlacesToolbarHelper = {
let viewElt = this._viewElt;
if (!viewElt || viewElt._placesView)
return;
// CustomizableUI.addListener is idempotent, so we can safely
// call this multiple times.
CustomizableUI.addListener(this);
+ if (!this._isObservingToolbars) {
+ this._isObservingToolbars = true;
+ window.addEventListener("toolbarvisibilitychange", this);
+ }
+
// If the bookmarks toolbar item is:
// - not in a toolbar, or;
// - the toolbar is collapsed, or;
// - the toolbar is hidden some other way:
// don't initialize. Also, there is no need to initialize the toolbar if
// customizing, because that will happen when the customization is done.
let toolbar = this._getParentToolbar(viewElt);
if (!toolbar || toolbar.collapsed || this._isCustomizing ||
- getComputedStyle(toolbar, "").display == "none")
+ getComputedStyle(toolbar, "").display == "none") {
return;
+ }
new PlacesToolbar(this._place);
if (forceToolbarOverflowCheck) {
viewElt._placesView.updateOverflowStatus();
}
},
+ handleEvent(event) {
+ switch (event.type) {
+ case "toolbarvisibilitychange":
+ if (event.target == this._viewElt.parentNode.parentNode)
+ this._resetView();
+ break;
+ }
+ },
+
uninit: function PTH_uninit() {
+ if (this._isObservingToolbars) {
+ delete this._isObservingToolbars;
+ window.removeEventListener("toolbarvisibilitychange", this);
+ }
CustomizableUI.removeListener(this);
},
customizeStart: function PTH_customizeStart() {
try {
let viewElt = this._viewElt;
if (viewElt && viewElt._placesView)
viewElt._placesView.uninit();
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5512,17 +5512,16 @@ function setToolbarVisibility(toolbar, i
detail: {
visible: isVisible
},
bubbles: true
};
let event = new CustomEvent("toolbarvisibilitychange", eventParams);
toolbar.dispatchEvent(event);
- PlacesToolbarHelper.init();
BookmarkingUI.onToolbarVisibilityChange();
}
function updateToggleControlLabel(control) {
if (!control.hasAttribute("label-checked")) {
return;
}