Bug 1902342 - Bookmarks Toolbar empty message flickers with opening new windows. r=daisuke,desktop-theme-reviewers,places-reviewers,dao
Differential Revision: https://phabricator.services.mozilla.com/D220058
This commit is contained in:
@@ -1108,12 +1108,13 @@ var PlacesToolbarHelper = {
|
||||
);
|
||||
|
||||
if (toolbar.id == "PersonalToolbar") {
|
||||
if (!toolbar.hasAttribute("initialized")) {
|
||||
toolbar.setAttribute("initialized", "true");
|
||||
}
|
||||
// We just created a new view, thus we must check again the empty toolbar
|
||||
// message, regardless of "initialized".
|
||||
BookmarkingUI.updateEmptyToolbarMessage().catch(console.error);
|
||||
BookmarkingUI.updateEmptyToolbarMessage()
|
||||
.finally(() => {
|
||||
toolbar.toggleAttribute("initialized", true);
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1530,8 +1531,7 @@ var BookmarkingUI = {
|
||||
* We hide it in customize mode, unless there's nothing on the toolbar.
|
||||
*/
|
||||
async updateEmptyToolbarMessage() {
|
||||
let checkNumBookmarksOnToolbar = false;
|
||||
let hasVisibleChildren = (() => {
|
||||
let { initialHiddenState, checkHasBookmarks } = (() => {
|
||||
// Do we have visible kids?
|
||||
if (
|
||||
this.toolbar.querySelector(
|
||||
@@ -1541,25 +1541,29 @@ var BookmarkingUI = {
|
||||
:scope > toolbaritem:not([hidden], #personal-bookmarks)`
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
return { initialHiddenState: true, checkHasBookmarks: false };
|
||||
}
|
||||
if (!this.toolbar.hasAttribute("initialized") && !this._isCustomizing) {
|
||||
// If the bookmarks are here but it's early in startup, show the
|
||||
// message. It'll get made visibility: hidden early in startup anyway -
|
||||
// it's just to ensure the toolbar has height.
|
||||
return false;
|
||||
|
||||
if (this._isCustomizing) {
|
||||
return { initialHiddenState: true, checkHasBookmarks: false };
|
||||
}
|
||||
// Hmm, apparently not. Check for bookmarks or customize mode:
|
||||
|
||||
// If bookmarks have been moved out of the toolbar, we show the message.
|
||||
let bookmarksToolbarItemsPlacement =
|
||||
CustomizableUI.getPlacementOfWidget("personal-bookmarks");
|
||||
let bookmarksItemInToolbar =
|
||||
bookmarksToolbarItemsPlacement?.area == CustomizableUI.AREA_BOOKMARKS;
|
||||
if (!bookmarksItemInToolbar) {
|
||||
return false;
|
||||
return { initialHiddenState: false, checkHasBookmarks: false };
|
||||
}
|
||||
if (this._isCustomizing) {
|
||||
return true;
|
||||
|
||||
if (!this.toolbar.hasAttribute("initialized")) {
|
||||
// If the toolbar has not been initialized yet, unhide the message, it
|
||||
// will be made 0-width and visibility: hidden anyway, to keep the
|
||||
// toolbar height stable.
|
||||
return { initialHiddenState: false, checkHasBookmarks: true };
|
||||
}
|
||||
|
||||
// Check visible bookmark nodes.
|
||||
if (
|
||||
this.toolbar.querySelector(
|
||||
@@ -1567,19 +1571,16 @@ var BookmarkingUI = {
|
||||
#PlacesToolbarItems > toolbarbutton`
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
return { initialHiddenState: true, checkHasBookmarks: false };
|
||||
}
|
||||
checkNumBookmarksOnToolbar = true;
|
||||
return false;
|
||||
return { initialHiddenState: true, checkHasBookmarks: true };
|
||||
})();
|
||||
|
||||
if (checkNumBookmarksOnToolbar) {
|
||||
hasVisibleChildren = !(await PlacesToolbarHelper.getIsEmpty());
|
||||
}
|
||||
|
||||
let emptyMsg = document.getElementById("personal-toolbar-empty");
|
||||
emptyMsg.hidden = hasVisibleChildren;
|
||||
emptyMsg.toggleAttribute("nowidth", !hasVisibleChildren);
|
||||
emptyMsg.hidden = initialHiddenState;
|
||||
if (checkHasBookmarks) {
|
||||
emptyMsg.hidden = !(await PlacesToolbarHelper.getIsEmpty());
|
||||
}
|
||||
},
|
||||
|
||||
openLibraryIfLinkClicked(event) {
|
||||
|
||||
@@ -437,28 +437,11 @@ body {
|
||||
|
||||
/* Bookmarks toolbar empty message */
|
||||
|
||||
/* If the toolbar is not initialized set a zero width, but retain height. */
|
||||
&[collapsed=false]:not([initialized]) > #personal-toolbar-empty {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make the empty bookmarks toolbar message take up no horizontal space.
|
||||
* This avoids two issues:
|
||||
* 1) drag/drop of urls/bookmarks to the toolbar not working, because they
|
||||
* land on the personal-toolbar-empty element.
|
||||
* 2) buttons in the toolbar moving horizontally while the window opens,
|
||||
* because the element is first shown at full width and then completely
|
||||
* hidden.
|
||||
* TODO(emilio): The comment above was never quite true (the message did take
|
||||
* horizontal space, see bug 1812636). Figure out how much of this rule is
|
||||
* really needed.
|
||||
*/
|
||||
&[collapsed=false] > #personal-toolbar-empty[nowidth] > #personal-toolbar-empty-description {
|
||||
margin-inline: 0;
|
||||
min-width: 0;
|
||||
white-space: nowrap;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 0;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Bookmarks toolbar in customize mode */
|
||||
@@ -471,6 +454,10 @@ body {
|
||||
}
|
||||
}
|
||||
|
||||
#personal-toolbar-empty-description {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
#personal-bookmarks {
|
||||
position: relative;
|
||||
-moz-window-dragging: inherit;
|
||||
|
||||
Reference in New Issue
Block a user